improve Dockerfile size and safety
This commit is contained in:
23
Dockerfile
23
Dockerfile
@ -7,7 +7,7 @@ ENV SCOPE=${SCOPE}
|
|||||||
FROM base AS pruner
|
FROM base AS pruner
|
||||||
RUN yarn global add turbo@1.2.9
|
RUN yarn global add turbo@1.2.9
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN turbo prune --scope=${SCOPE} --docker
|
RUN turbo prune --scope="${SCOPE}" --docker
|
||||||
|
|
||||||
FROM base AS installer
|
FROM base AS installer
|
||||||
COPY --from=pruner /app/out/json/ .
|
COPY --from=pruner /app/out/json/ .
|
||||||
@ -15,12 +15,13 @@ COPY --from=pruner /app/out/yarn.lock ./yarn.lock
|
|||||||
RUN yarn install --frozen-lockfile
|
RUN yarn install --frozen-lockfile
|
||||||
|
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
COPY --from=installer /app/ .
|
COPY --from=installer /app/ .
|
||||||
COPY --from=pruner /app/out/full/ .
|
COPY --from=pruner /app/out/full/ .
|
||||||
COPY ./apps/${SCOPE}/.env.docker ./apps/${SCOPE}/.env.production
|
COPY ./apps/${SCOPE}/.env.docker ./apps/${SCOPE}/.env.production
|
||||||
COPY ./apps/${SCOPE}/.env.docker ./apps/${SCOPE}/.env.local
|
COPY ./apps/${SCOPE}/.env.docker ./apps/${SCOPE}/.env.local
|
||||||
RUN apt-get -qy update && apt-get -qy install openssl
|
RUN apt-get -qy update && apt-get -qy --no-install-recommends install openssl
|
||||||
RUN yarn turbo run build --scope=${SCOPE} --include-dependencies --no-deps
|
RUN yarn turbo run build --scope="${SCOPE}" --include-dependencies --no-deps
|
||||||
RUN find . -name node_modules | xargs rm -rf
|
RUN find . -name node_modules | xargs rm -rf
|
||||||
|
|
||||||
FROM base AS runner
|
FROM base AS runner
|
||||||
@ -34,13 +35,17 @@ COPY --from=builder /app/apps/${SCOPE}/package.json ./package.json
|
|||||||
COPY --from=builder /app/apps/${SCOPE}/.next/standalone ./
|
COPY --from=builder /app/apps/${SCOPE}/.next/standalone ./
|
||||||
COPY --from=builder /app/apps/${SCOPE}/.next/static ./.next/static
|
COPY --from=builder /app/apps/${SCOPE}/.next/static ./.next/static
|
||||||
COPY --from=builder /app/apps/${SCOPE}/.env.docker ./.env.production
|
COPY --from=builder /app/apps/${SCOPE}/.env.docker ./.env.production
|
||||||
RUN apt-get -qy update && apt-get -qy install openssl
|
RUN apt-get -qy update \
|
||||||
|
&& apt-get -qy --no-install-recommends install \
|
||||||
|
openssl \
|
||||||
|
&& apt-get autoremove -yq \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY env.sh ./
|
COPY env.sh ${SCOPE}-entrypoint.sh ./
|
||||||
COPY ${SCOPE}-entrypoint.sh ./
|
RUN chmod +x ./"${SCOPE}"-entrypoint.sh \
|
||||||
RUN chmod +x ./${SCOPE}-entrypoint.sh
|
&& chmod +x ./env.sh
|
||||||
RUN chmod +x ./env.sh
|
ENTRYPOINT ./"${SCOPE}"-entrypoint.sh
|
||||||
ENTRYPOINT ./${SCOPE}-entrypoint.sh
|
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV PORT 3000
|
ENV PORT 3000
|
Reference in New Issue
Block a user