Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
FROM node:22-slim
RUN apt update \
&& apt --no-install-recommends install -y curl \
&& apt clean
# Our first stage, that is the Builder
FROM node:22-slim AS thumbnail-api-builder
WORKDIR /opt/thumbnail-api
COPY src /opt/thumbnail-api/src
COPY package.json /opt/thumbnail-api
COPY package-lock.json /opt/thumbnail-api
COPY tsconfig.json /opt/thumbnail-api
COPY eslint.config.mjs /opt/thumbnail-api
RUN npm install --ignore-scripts && npm run clean && npm run build

FROM node:22-slim AS thumbnail-api-prod
RUN apt update \
&& apt --no-install-recommends install -y curl \
&& apt clean
WORKDIR /opt/thumbnail-api
COPY package.json .
COPY package-lock.json .
COPY --from=thumbnail-api-builder /opt/thumbnail-api/dist /opt/thumbnail-api/dist
RUN chown -R node:node /opt/thumbnail-api
USER node
EXPOSE 3000
HEALTHCHECK CMD ["curl", "-f", "http://localhost:3000/health"]
RUN npm run clean \
&& npm ci --ignore-scripts \
&& npm run build
RUN npm install --omit=dev --omit=optional --ignore-scripts
CMD ["npm", "run", "start", "-s"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"build": "tsc",
"clean": "rm -r dist thumbnail-api.zip 2> /dev/null ; exit 0",
"clean": "rm -r dist 2> /dev/null ; exit 0",
"start": "node dist/src/main.js",
"lint": "npx eslint",
"format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"",
Expand Down
Loading