diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f06235c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +dist diff --git a/Dockerfile b/Dockerfile index 1f49688..3bcec9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM nginx:latest - -COPY config/docker/nginx.conf /etc/nginx/conf.d - +FROM node:erbium +WORKDIR /app +COPY package.json yarn.lock ./ +RUN yarn +ENTRYPOINT yarn dev diff --git a/Dockerfile.production b/Dockerfile.production new file mode 100644 index 0000000..da8a8dc --- /dev/null +++ b/Dockerfile.production @@ -0,0 +1,12 @@ +FROM node:erbium-alpine as build-stage +WORKDIR /app +COPY package.json . +RUN yarn +COPY . . +RUN yarn build + +FROM nginx:1.17.9-alpine as production-stage +RUN mkdir /app +COPY --from=build-stage /app/dist /app +COPY config/docker/nginx.conf /etc/nginx/conf.d/nexus-timers.conf + diff --git a/README.md b/README.md index efb400a..6549d62 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,9 @@ yarn build --report ``` For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). + +## Run via docker + +`docker-compose up` will build an image with all dependencies, then bind the root directory to the container + +`docker build . -f Dockerfile.production` will create an image with all project minified, optimized and served via nginx diff --git a/config/docker/nginx.conf b/config/docker/nginx.conf index a946082..01367b2 100644 --- a/config/docker/nginx.conf +++ b/config/docker/nginx.conf @@ -1,7 +1,7 @@ server { listen 80; server_name nexus-timers.local.tld; - root /usr/share/nginx/html/dist; + root /app; access_log /var/log/nginx/nexus-timers.access.log; diff --git a/docker-compose.yml b/docker-compose.yml index 2cce654..a5c0c1e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ -nexus-timers: +dev: build: . volumes: - - .:/usr/share/nginx/html + - .:/app + - /app/node_modules ports: - - 80:80 + - 8080:8080