Created
October 25, 2022 14:27
-
-
Save aaberg/56ac7ed9e34502c45e6a1d1ecff526c7 to your computer and use it in GitHub Desktop.
Dockerfile for a svelte kit application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Base image for | |
FROM node:16 as dependencies_base | |
ARG NPM_TOKEN | |
WORKDIR /app | |
COPY package*.json ./ | |
RUN npm config set @aaberg:registry https://gitlab.com/api/v4/packages/npm/ | |
RUN npm config set -- '//gitlab.com/api/v4/packages/npm/:_authToken' "${NPM_TOKEN}" | |
# Dependencies used for build | |
FROM dependencies_base as dependencies | |
RUN npm install --ignore-scripts | |
RUN npm audit fix | |
# Runtime dependencies used runtime | |
FROM dependencies_base as runtime_dependencies | |
RUN ls | |
RUN npm install --omit=dev --ignore-scripts | |
RUN ls node_modules | |
# Build | |
FROM node:16 as build | |
ARG NPM_TOKEN | |
WORKDIR /app | |
COPY --from=dependencies /app/node_modules ./node_modules | |
COPY . . | |
RUN npm install | |
RUN npm run build | |
# Application | |
FROM node:16-alpine as runner | |
WORKDIR /app | |
RUN node --version | |
COPY --from=build /app/package*.json ./ | |
COPY --from=build /app/build . | |
COPY --from=runtime_dependencies /app/node_modules ./node_modules | |
USER node | |
EXPOSE 3000 | |
ENV PORT 3000 | |
ENV NODE_ENV Docker | |
CMD ["node", "index"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment