simple-links/Dockerfile

29 lines
619 B
Docker
Raw Normal View History

2023-07-12 11:21:38 +01:00
# Use a smaller base image
FROM node:lts-slim
2023-07-08 20:49:08 +01:00
2023-07-01 20:43:53 +00:00
ENV NODE_ENV=production
WORKDIR /usr/src/app
2023-07-12 11:21:38 +01:00
# Copy package.json and package-lock.json separately to fully utilize Docker layer caching
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --production --silent && npm cache clean --force
2023-07-12 11:28:23 +01:00
# Copy only necessary files for production
COPY .next ./.next
COPY public ./public
COPY config.json ./
COPY next.config.js ./
2023-07-01 22:17:34 +01:00
2023-07-12 11:21:38 +01:00
# Opt out of Next.js telemetry
2023-07-02 12:05:27 +01:00
RUN npx next telemetry disable
2023-07-12 11:21:38 +01:00
# Expose port 3000
EXPOSE 3000
# Set permissions and user
2023-07-02 15:04:33 +01:00
RUN chown -R node /usr/src/app
USER node
2023-07-12 11:21:38 +01:00
# Start the app
CMD ["npm", "start"]