Skip to content

Instantly share code, notes, and snippets.

@Maxim-Kolmogorov
Created December 10, 2023 18:24
Show Gist options
  • Save Maxim-Kolmogorov/0f9816effc2cb2da650dc3ccab702a31 to your computer and use it in GitHub Desktop.
Save Maxim-Kolmogorov/0f9816effc2cb2da650dc3ccab702a31 to your computer and use it in GitHub Desktop.
Nuxt 3 Docker example
version: "3.3"
# Указываем раздел со связанными сервисами
services:
nginx:
depends_on:
- nuxt
image: nginx:latest
ports:
- '80:80'
volumes:
# Используем свой nginx конфиг, он заменит дефолтный в контейнере
- ./nginx:/etc/nginx/conf.d
# Монтируем папку с логами на хост машину для более удобного доступа
- ./logs:/var/log/nginx/
restart: always
nuxt:
build: ./nuxt
expose:
- '3000'
restart: always
FROM node:18.16.0
ENV APP_ROOT /web
WORKDIR ${APP_ROOT}
ADD . ${APP_ROOT}
RUN npm ci
RUN npm run build
CMD node .output/server/index.mjs
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
server {
listen 80 default_server;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location / {
expires $expires;
proxy_redirect off;
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;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://nuxt:3000;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment