hexabot/api/Dockerfile

50 lines
746 B
Docker
Raw Normal View History

2024-09-10 09:50:11 +00:00
FROM node:18-alpine AS builder
WORKDIR /app
COPY . .
2024-09-27 10:22:18 +00:00
RUN npm update -g npm
RUN npm config set registry https://registry.npmjs.com/
RUN npm run preinstall
RUN npm i --verbose --maxsockets 6
RUN npm run build
2024-09-27 22:57:15 +00:00
FROM node:18-alpine AS development
2024-09-10 09:50:11 +00:00
WORKDIR /app
COPY --from=builder /app/package*.json ./
2024-09-27 10:22:18 +00:00
COPY --from=builder /app/ .
2024-09-10 09:50:11 +00:00
2024-09-27 22:57:15 +00:00
ENV NODE_ENV=development
2024-09-10 09:50:11 +00:00
2024-09-27 22:57:15 +00:00
RUN npm install
2024-09-10 09:50:11 +00:00
2024-09-27 10:22:18 +00:00
EXPOSE 3000
2024-09-10 09:50:11 +00:00
2024-09-27 22:57:15 +00:00
CMD ["npm", "run", "start:debug"]
2024-09-10 09:50:11 +00:00
2024-09-27 22:57:15 +00:00
FROM node:18-alpine AS production
2024-09-10 09:50:11 +00:00
WORKDIR /app
2024-09-27 10:22:18 +00:00
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/ .
2024-09-27 22:57:15 +00:00
COPY --from=builder /app/node_modules ./node_modules
2024-09-27 10:22:18 +00:00
2024-09-27 22:57:15 +00:00
ENV NODE_ENV=production
2024-09-10 09:50:11 +00:00
2024-09-27 22:57:15 +00:00
# Run npm prune to remove dev dependencies
RUN npm prune --production
2024-09-10 09:50:11 +00:00
EXPOSE 3000
2024-09-27 22:57:15 +00:00
CMD ["npm", "run", "start:prod"]