-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document production Docker setup #1036
Comments
Hi. Actually there is a good example here: https://github.com/nuxt/nuxt.js/blob/dev/examples/docker-build/Dockerfile Still some parts like package manager are dependent on deployment/project requirements. Moving this issue to docs but still worth documenting there. |
Would love to get some help regarding how to deploy using Docker 😊 |
We currently deploy applications using docker-compose where we use both nginx as a proxy and a node server. I've added some examples of what we do below, however I've had to remove some information for privacy purposes. ProductionFolder Structure
docker-compose.yml version: '3.8'
networks:
nuxt:
services:
nginx:
image: nginx:1.19.10
container_name: nginx
networks:
- nuxt
depends_on:
- node
ports:
- "80:80"
- "443:443"
volumes:
- ./docker/nginx/templates:/etc/nginx/templates
node:
image: {We use this to store the docker image in our own docker reg using docker-compose push}
build:
context: ./
dockerfile: docker/Dockerfile
target: node
container_name: node
networks:
- nuxt
volumes:
- ./static/data/:/app/static/data Dockerfile
We use an ENTRYPOINT file instead of directly just writing #!/bin/bash
set -e
yarn start default.conf.template (NGINX Default Config Template) - Notice in the map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
server {
listen 80;
server_name _;
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://node:3000;
}
} CI/CDFor our CI/CD pipeline we modify it a bit since we don't want docker to use the entrypoint file and we don't need it to spin up an nginx proxy for unit testing. For that we use the following simple script to build for testing. Building
Starting the container docker run -d --name nuxt_test_container -it nuxt_test Executing Tests* docker exec nuxt_test_container yarn test Hope that gives a bit of insight @atinux |
Let's track in unjs/nitro#54. |
Is your feature request related to a problem? Please describe.
It's difficult to find an example of how to deploy a nuxt.js app as a Docker container. It would be great if there was official documentation for this.
It might be worth highlighting in the documentation that hosting a nuxt.js app as a Docker container might not always be an ideal solution. E.g. Blue/Green deployments can lead to blank pages during deployments. Combining a Docker container with assets on a CDN can be a good solution.
Additional context
Here's the Dockerfile I'm using:
Suggestions for improvements welcome
The text was updated successfully, but these errors were encountered: