Files
maestro/Dockerfile
T
2024-08-16 21:59:23 +00:00

43 lines
1.2 KiB
Docker

FROM node:18.17-alpine AS base_image
FROM base_image AS build_base
WORKDIR /app
RUN apk update
# needed packages to build dependencies from source
RUN apk add --no-cache aws-cli
COPY package*.json ./
# run aws cli without mounting secret, because CI already has AWS credentials
FROM build_base AS ci_image
RUN aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1
RUN npm ci
COPY . .
# unit test specific build
FROM ci_image AS test
ENTRYPOINT ["npm", "run", "test"]
# dev build
FROM build_base AS dev
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1
# flag --build-from-source is required to force-build sqlite3
RUN npm ci
COPY . .
ENTRYPOINT npm run start:dev
FROM ci_image AS prod_build
RUN npm run build
FROM base_image
WORKDIR /app
COPY --from=prod_build /app/dist ./dist
COPY --from=prod_build /app/node_modules ./node_modules
COPY --from=prod_build /app/package*.json ./
ENTRYPOINT npm run start:prod