Files
ButlerBot/Dockerfile
Jack b382a89d38
All checks were successful
Build and Publish Docker Image / build_and_push (push) Successful in 41s
Fix NPM repo permissions
2024-09-18 16:51:49 +00:00

43 lines
874 B
Docker

################################################
FROM node:lts-alpine AS base
# Create user and group
RUN mkdir /app && \
addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /app
WORKDIR /app
################################################
FROM base AS build
# Create app directory and copy the app
COPY package*.json tsconfig.json .npmrc ./
# Install
ARG NPM_TOKEN
ENV NPM_TOKEN ${NPM_TOKEN}
RUN npm install
# Copy the app
COPY src ./src
# Build
RUN npm run build
################################################
FROM node:lts-alpine
# Install dependencies but skip dev dependencies
COPY --from=build /app/package*.json /app/.npmrc ./
ARG NPM_TOKEN
ENV NPM_TOKEN ${NPM_TOKEN}
RUN npm install --only=production
# Copy the app
COPY --from=build /app/dist ./dist
# Start the app
ENTRYPOINT ["npm", "run"]
CMD ["start"]