Skip to content

Instantly share code, notes, and snippets.

@Morgbn
Last active September 23, 2021 10:08
Show Gist options
  • Save Morgbn/0b3db063b4bbf2324f4e6c11a8cccbfb to your computer and use it in GitHub Desktop.
Save Morgbn/0b3db063b4bbf2324f4e6c11a8cccbfb to your computer and use it in GitHub Desktop.
Fast (leverages the build cache) Nuxt.js Dockerfile with timezone + .dockerignore
FROM node:12.18.3-alpine
ARG TZ='Europe/Paris'
ENV TZ ${TZ}
# Installs
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& apk upgrade -U -a \
&& apk add \
tzdata \
&& rm -rf /var/cache/* \
&& mkdir /var/cache/apk
# set timezone
RUN cp /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo "${TZ}" > /etc/timezone \
&& apk del tzdata
# Create app directory
WORKDIR /src
# install dependencies
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# set app serving to permissive / assigned
ENV NUXT_HOST=0.0.0.0
# set app port
ENV NUXT_PORT=5000
# expose 5000 on container
EXPOSE 5000
CMD [ "npm", "run", "start" ]
@Morgbn
Copy link
Author

Morgbn commented Sep 23, 2021

📄 .dockerignore:
.git
.nuxt
/dist
/migrations
/node_modules
/uploads
.editorconfig
.env.example
docker-compose.production.yml
Dockerfile
npm-debug*
Procfile
README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment