This commit is contained in:
Shahrad Elahi 2023-12-19 14:55:45 +03:30
parent 2fc2ab4259
commit 479c4093fc
2 changed files with 23 additions and 33 deletions

View File

@ -26,37 +26,36 @@ COPY /config/torrc /etc/tor/torrc
COPY /scripts /scripts COPY /scripts /scripts
RUN chmod -R +x /scripts RUN chmod -R +x /scripts
COPY /bin /usr/local/bin COPY /bin /app/bin
RUN chmod -R +x /usr/local/bin RUN chmod -R +x /app/bin
ENV PATH="$PATH:/app/bin"
COPY web/package.json web/pnpm-lock.yaml ./
FROM base AS deps FROM base AS build
ENV PNPM_HOME="/pnpm" ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH" ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable RUN corepack enable
COPY web/package.json web/pnpm-lock.yaml /temp/dev/
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile -C /temp/dev/
COPY web/package.json web/pnpm-lock.yaml /temp/prod/
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod -C /temp/prod/
FROM base AS build
COPY --from=deps /temp/dev/node_modules node_modules
COPY web . COPY web .
# build RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile \
ENV NODE_ENV=production # build
RUN npm run build && NODE_ENV=production pnpm run build \
# Omit devDependencies
&& pnpm prune --prod \
# Move the goods to a temporary location
&& mv node_modules /tmp/node_modules \
&& mv build /tmp/build \
# Remove everything else
&& rm -rf ./*
FROM base AS release FROM base AS release
COPY --from=deps /temp/prod/node_modules node_modules COPY --from=build /tmp/node_modules node_modules
COPY --from=build /app/build build COPY --from=build /tmp/build build
COPY --from=build /app/package.json .
ENV NODE_ENV=production ENV NODE_ENV=production
ENV LOG_LEVEL=error ENV LOG_LEVEL=error

View File

@ -27,25 +27,16 @@ COPY /config/obfs4-bridges.conf /etc/torrc.d/obfs4-bridges.conf
COPY /scripts /scripts COPY /scripts /scripts
RUN chmod -R +x /scripts RUN chmod -R +x /scripts
COPY /bin /usr/local/bin COPY /bin /app/bin
RUN chmod -R +x /usr/local/bin RUN chmod -R +x /app/bin
ENV PATH="$PATH:/app/bin"
FROM base AS deps
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN mkdir -p /temp/dev/
COPY web/package.json web/pnpm-lock.yaml /temp/dev/
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile -C /temp/dev/
FROM base AS runner FROM base AS runner
COPY --from=deps /temp/dev/node_modules node_modules ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY docker-entrypoint.sh /entrypoint.sh COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh