diff --git a/docker-compose.dev.yml b/compose.yml similarity index 65% rename from docker-compose.dev.yml rename to compose.yml index c089d0f..f9a8c4b 100644 --- a/docker-compose.dev.yml +++ b/compose.yml @@ -1,22 +1,38 @@ version: '3.8' services: web: - restart: 'always' build: - context: . - target: development + context: ./website + target: production + network: host container_name: web volumes: - - './:/app' - network_mode: host + - './website/nginx/conf.d:/etc/nginx/conf.d:rw' + networks: + - directus + ports: + - '80' depends_on: - directus + - nginx environment: - DIRECTUS_URL=http://localhost:8055 - DIRECTUS_EMAIL=admin@example.com - DIRECTUS_PASSWORD=d1r3ctu5 - DIRECTUS_STATIC_TOKEN= + nginx: + container_name: nginx + image: nginx:1.23.3-alpine + volumes: + - './nginx/nginx.conf:/etc/nginx/nginx.conf' + ports: + - '80:80' + depends_on: + - directus + networks: + - directus + database: image: postgres:15-alpine container_name: database @@ -31,10 +47,16 @@ services: networks: - directus + # cache: + # container_name: cache + # image: redis:6 + # networks: + # - directus + directus: image: directus/directus:latest ports: - - '8055:8055' + - 8055:8055 volumes: - uploads:/directus/uploads depends_on: @@ -54,6 +76,10 @@ services: DB_USER: 'directus' DB_PASSWORD: 'directus' + # CACHE_ENABLED: 'false' + # CACHE_STORE: 'redis' + # CACHE_REDIS: 'redis://cache:6379' + ADMIN_EMAIL: 'admin@example.com' ADMIN_PASSWORD: 'd1r3ctu5' volumes: diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index b0b75e8..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,70 +0,0 @@ -version: '3.8' -services: - web: - build: - context: . - target: production - container_name: web - volumes: - - './nginx/conf.d:/etc/nginx/conf.d' - - './nginx/nginx.conf:/etc/nginx/nginx.conf' - ports: - - '80:80' - networks: - - directus - depends_on: - - directus - - database: - image: postgres:15-alpine - container_name: database - environment: - POSTGRES_USER: directus - POSTGRES_PASSWORD: directus - POSTGRES_DB: directus - volumes: - - db-data:/var/lib/postgresql/data - ports: - - 5432:5432 - networks: - - directus - - cache: - container_name: cache - image: redis:6 - networks: - - directus - - directus: - image: directus/directus:latest - ports: - - 8055 - volumes: - - uploads:/directus/uploads - depends_on: - - cache - - database - networks: - - directus - environment: - KEY: '255d861b-5ea1-5996-9aa3-922530ec40b1' - SECRET: '6116487b-cda1-52c2-b5b5-c8022c45e263' - - DB_CLIENT: 'pg' - DB_HOST: 'database' - DB_PORT: '5432' - DB_DATABASE: 'directus' - DB_USER: 'directus' - DB_PASSWORD: 'directus' - - CACHE_ENABLED: 'true' - CACHE_STORE: 'redis' - CACHE_REDIS: 'redis://cache:6379' - - ADMIN_EMAIL: 'admin@example.com' - ADMIN_PASSWORD: 'd1r3ctu5' -volumes: - db-data: - uploads: -networks: - directus: diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf deleted file mode 100644 index 694e4d2..0000000 --- a/nginx/conf.d/default.conf +++ /dev/null @@ -1,52 +0,0 @@ -server_tokens off; - -server { - listen 80; - listen [::]:80; - - server_name localhost; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - - location ~* \.(css|js|png|jpe?g|wepb|ico|gif|svg)$ { - add_header Cache-Control "public"; - access_log off; - expires 30d; - } - } - - error_page 500 502 503 504 /50x.html; - error_page 404 /404.html; - - location = /50x.html { - root /usr/share/nginx/html; - } -} - -server { - listen 80; - listen [::]:80; - - client_max_body_size 100M; - - server_name cms.localhost; - - location / { - proxy_pass http://directus:8055; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header REMOTE-HOST $remote_addr; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - - proxy_connect_timeout 30s; - proxy_read_timeout 86400s; - proxy_send_timeout 30s; - proxy_http_version 1.1; - - add_header X-Cache $upstream_cache_status; - } -} \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 6775578..6b4c1f6 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -4,11 +4,7 @@ worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - +events { worker_connections 1024; } http { include /etc/nginx/mime.types; @@ -25,5 +21,49 @@ http { keepalive_timeout 65; - include /etc/nginx/conf.d/*.conf; + server_tokens off; + + server { + listen 80; + listen [::]:80; + + server_name localhost; + + location / { + proxy_pass http://web:80; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + } + + server { + listen 80; + listen [::]:80; + + client_max_body_size 100M; + + server_name cms.localhost; + + location / { + proxy_pass http://directus:8055; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header REMOTE-HOST $remote_addr; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + proxy_connect_timeout 30s; + proxy_read_timeout 86400s; + proxy_send_timeout 30s; + proxy_http_version 1.1; + + add_header X-Cache $upstream_cache_status; + } + } } \ No newline at end of file diff --git a/.dockerignore b/website/.dockerignore similarity index 50% rename from .dockerignore rename to website/.dockerignore index 7d67791..336982e 100644 --- a/.dockerignore +++ b/website/.dockerignore @@ -1,2 +1,3 @@ node_modules/ -uploads/ \ No newline at end of file +uploads/ +dist/ \ No newline at end of file diff --git a/.env.example b/website/.env.example similarity index 100% rename from .env.example rename to website/.env.example diff --git a/Dockerfile b/website/Dockerfile similarity index 88% rename from Dockerfile rename to website/Dockerfile index 5f1d830..f035a43 100644 --- a/Dockerfile +++ b/website/Dockerfile @@ -17,13 +17,13 @@ EXPOSE 3000 CMD [ "npm", "start" ] FROM development as builder +WORKDIR /app RUN npm run build FROM ${NGINX_IMAGE} as production COPY --from=builder /app/dist /usr/share/nginx/html COPY --from=builder /app/nginx/conf.d /etc/nginx/conf.d -COPY --from=builder /app/nginx/nginx.conf /etc/nginx/nginx.conf EXPOSE 80 diff --git a/README.md b/website/README.md similarity index 100% rename from README.md rename to website/README.md diff --git a/astro.config.mjs b/website/astro.config.mjs similarity index 100% rename from astro.config.mjs rename to website/astro.config.mjs diff --git a/lib/api.ts b/website/lib/api.ts similarity index 100% rename from lib/api.ts rename to website/lib/api.ts diff --git a/lib/directus-collections.d.ts b/website/lib/directus-collections.d.ts similarity index 100% rename from lib/directus-collections.d.ts rename to website/lib/directus-collections.d.ts diff --git a/lib/directus.ts b/website/lib/directus.ts similarity index 100% rename from lib/directus.ts rename to website/lib/directus.ts diff --git a/website/nginx/conf.d/default.conf b/website/nginx/conf.d/default.conf new file mode 100644 index 0000000..8693d39 --- /dev/null +++ b/website/nginx/conf.d/default.conf @@ -0,0 +1,24 @@ +server { + listen 80; + listen [::]:80; + + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + + location ~* \.(css|js|png|jpe?g|wepb|ico|gif|svg)$ { + add_header Cache-Control "public"; + access_log off; + expires 30d; + } + } + + error_page 500 502 503 504 /50x.html; + error_page 404 /404.html; + + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/nginx/conf.d/gzip.conf b/website/nginx/conf.d/gzip.conf similarity index 100% rename from nginx/conf.d/gzip.conf rename to website/nginx/conf.d/gzip.conf diff --git a/package-lock.json b/website/package-lock.json similarity index 100% rename from package-lock.json rename to website/package-lock.json diff --git a/package.json b/website/package.json similarity index 100% rename from package.json rename to website/package.json diff --git a/public/favicon.svg b/website/public/favicon.svg similarity index 100% rename from public/favicon.svg rename to website/public/favicon.svg diff --git a/src/components/BaseHead.astro b/website/src/components/BaseHead.astro similarity index 100% rename from src/components/BaseHead.astro rename to website/src/components/BaseHead.astro diff --git a/src/components/Footer.astro b/website/src/components/Footer.astro similarity index 100% rename from src/components/Footer.astro rename to website/src/components/Footer.astro diff --git a/src/components/Header.astro b/website/src/components/Header.astro similarity index 100% rename from src/components/Header.astro rename to website/src/components/Header.astro diff --git a/src/env.d.ts b/website/src/env.d.ts similarity index 100% rename from src/env.d.ts rename to website/src/env.d.ts diff --git a/src/layouts/PageLayout.astro b/website/src/layouts/PageLayout.astro similarity index 100% rename from src/layouts/PageLayout.astro rename to website/src/layouts/PageLayout.astro diff --git a/src/pages/404.astro b/website/src/pages/404.astro similarity index 100% rename from src/pages/404.astro rename to website/src/pages/404.astro diff --git a/src/pages/about.astro b/website/src/pages/about.astro similarity index 100% rename from src/pages/about.astro rename to website/src/pages/about.astro diff --git a/src/pages/blog/[slug].astro b/website/src/pages/blog/[slug].astro similarity index 100% rename from src/pages/blog/[slug].astro rename to website/src/pages/blog/[slug].astro diff --git a/src/pages/contact.astro b/website/src/pages/contact.astro similarity index 100% rename from src/pages/contact.astro rename to website/src/pages/contact.astro diff --git a/src/pages/index.astro b/website/src/pages/index.astro similarity index 100% rename from src/pages/index.astro rename to website/src/pages/index.astro diff --git a/src/styles/global.css b/website/src/styles/global.css similarity index 100% rename from src/styles/global.css rename to website/src/styles/global.css diff --git a/tailwind.config.cjs b/website/tailwind.config.cjs similarity index 100% rename from tailwind.config.cjs rename to website/tailwind.config.cjs diff --git a/tsconfig.json b/website/tsconfig.json similarity index 100% rename from tsconfig.json rename to website/tsconfig.json