diff --git a/Dockerfile b/Dockerfile index a765231..1197b5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,28 @@ +# DEP STAGE +FROM node:18-alpine as deps + +WORKDIR /app + +# We need build tools if we need to build packages +RUN apk add --no-cache python3 make g++ + +# Fetch and install runtime dependencies +COPY package.json yarn.lock ./ +RUN yarn install --production + +########################################### + # BUILD STAGE FROM node:18-alpine as build WORKDIR /app -# Fetch dependencies +# We need build tools if we need to build packages +RUN apk add --no-cache python3 make g++ + +# Fetch runtime dependencies from deps stage +COPY --from=deps /app/node_modules ./node_modules +# Then install dev dependencies on top of that COPY package.json yarn.lock ./ RUN yarn install @@ -13,6 +32,8 @@ COPY . ./ # Build application RUN yarn build +########################################### + # RUN STAGE FROM node:18-alpine as run @@ -27,13 +48,12 @@ ENV DISCORD_GENERAL_LOGGING_ENABLED=false ENV DISCORD_REGISTER_COMMANDS=true ENV DISCORD_REGISTER_COMMANDS_AS_GLOBAL=true +# Fetch runtime dependencies from deps stage +COPY --from=deps /app/node_modules ./node_modules + # Copy build source COPY --from=build /app/built ./built -# Fetch runtime dependencies -COPY package.json yarn.lock ./ -RUN yarn install --production - # Default ENV arguments for application ENV REACTION_HANDLING_DISABLED=false ENV GRAPHQL_DEBUG=false