Skip to content

Instantly share code, notes, and snippets.

@Gomah
Last active March 23, 2021 14:33
Show Gist options
  • Save Gomah/876f15355a636ad105e36d5a41bfd366 to your computer and use it in GitHub Desktop.
Save Gomah/876f15355a636ad105e36d5a41bfd366 to your computer and use it in GitHub Desktop.
Nuxt.js Dockerfile :: Now.sh
FROM node:10-alpine
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
COPY yarn.lock /usr/src/app/
RUN yarn install
# Set environment variables
ENV NODE_ENV production
ENV NUXT_HOST 0.0.0.0
ENV NUXT_PORT 3000
# Bundle app source
COPY . /usr/src/app
RUN yarn build
# Clear the cache
RUN yarn cache clean
EXPOSE 3000
CMD [ "yarn", "start" ]
@creazy231
Copy link

Will this Dockerfile make nuxt work in now.sh version 2?

@Gomah
Copy link
Author

Gomah commented Apr 6, 2019

@crezy231, unfortunately not, I recommend using the nuxt-builder for now v2: https://github.com/nuxt/now-builder

This Dockerfile can still be used in v1 (https://zeit.co/blog/serverless-docker) or in any container service.

@blowsie
Copy link

blowsie commented Sep 2, 2019

Have you considered building the nuxt app files before building the image?

@Gomah
Copy link
Author

Gomah commented Feb 26, 2020

@blowsie - Yes, but Nuxt does not support dynamic runtime environment: nuxt/nuxt#5100

@blowsie
Copy link

blowsie commented Feb 26, 2020

sure, but there are known work arounds

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