index/Dockerfile

37 lines
804 B
Docker

ARG NODE_ENV=development
ARG HOST=localhost
ARG PORT=3000
FROM node:18-alpine as build
RUN apk update && apk upgrade
# Create application directory
WORKDIR /app
# Copy package files to the application directory and install dependencies
COPY package* ./
RUN npm install
# Copy everything else from the project
COPY . ./
RUN npm run build
FROM node:18-alpine as production
RUN apk update && apk upgrade && apk add dumb-init && adduser -D nuxt
# Set non-root user
USER nuxt
# Set working directory
WORKDIR /opt/index
COPY --chown=nuxt:nuxt --from=build /app/.output ./
# Expose the listening port
EXPOSE ${PORT}
# Set Nitro variables and run the application
# https://go.enderman.ch/vws4k
ENV HOST=${HOST} PORT=${PORT} NODE_ENV=${NODE_ENV}
CMD ["dumb-init", "node", "/opt/index/server/index.mjs"]