2023-11-07 20:12:06 +00:00
|
|
|
FROM node:alpine as base
|
2023-11-02 13:02:33 +00:00
|
|
|
LABEL Maintainer="Shahrad Elahi <https://github.com/shahradelahi>"
|
2023-11-05 16:20:21 +00:00
|
|
|
WORKDIR /app
|
2023-09-06 10:23:31 +00:00
|
|
|
|
2023-09-24 19:18:39 +00:00
|
|
|
ENV TZ=UTC
|
|
|
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
2023-09-06 10:23:31 +00:00
|
|
|
|
2023-09-27 07:01:52 +00:00
|
|
|
COPY --from=chriswayg/tor-alpine:latest /usr/local/bin/obfs4proxy /usr/local/bin/obfs4proxy
|
|
|
|
COPY --from=chriswayg/tor-alpine:latest /usr/local/bin/meek-server /usr/local/bin/meek-server
|
|
|
|
|
2023-11-02 13:02:33 +00:00
|
|
|
# Update and upgrade packages
|
2023-12-10 23:20:54 +00:00
|
|
|
RUN apk update && apk upgrade \
|
|
|
|
# Install required packages
|
|
|
|
&& apk add -U --no-cache \
|
|
|
|
iproute2 iptables net-tools \
|
2023-12-19 05:00:54 +00:00
|
|
|
screen curl bash \
|
2023-12-10 23:20:54 +00:00
|
|
|
wireguard-tools \
|
|
|
|
openssl \
|
|
|
|
tor \
|
|
|
|
redis \
|
|
|
|
# Clear APK cache
|
|
|
|
&& rm -rf /var/cache/apk/*
|
2023-09-06 10:23:31 +00:00
|
|
|
|
2023-12-19 09:51:23 +00:00
|
|
|
COPY /config/torrc /etc/tor/torrc
|
|
|
|
|
|
|
|
COPY /scripts /scripts
|
|
|
|
RUN chmod -R +x /scripts
|
|
|
|
|
|
|
|
COPY /bin /usr/local/bin
|
|
|
|
RUN chmod -R +x /usr/local/bin
|
|
|
|
|
2023-09-24 19:18:39 +00:00
|
|
|
|
2023-11-02 13:02:33 +00:00
|
|
|
FROM base AS deps
|
2023-09-24 19:18:39 +00:00
|
|
|
|
2023-11-07 22:06:32 +00:00
|
|
|
ENV PNPM_HOME="/pnpm"
|
|
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
|
|
RUN corepack enable
|
|
|
|
|
2023-11-07 20:12:06 +00:00
|
|
|
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/
|
2023-09-24 19:18:39 +00:00
|
|
|
|
2023-11-07 20:12:06 +00:00
|
|
|
COPY web/package.json web/pnpm-lock.yaml /temp/prod/
|
2023-11-08 21:38:45 +00:00
|
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod -C /temp/prod/
|
2023-09-24 19:18:39 +00:00
|
|
|
|
2023-09-06 10:23:31 +00:00
|
|
|
|
2023-11-02 13:02:33 +00:00
|
|
|
FROM base AS build
|
|
|
|
COPY --from=deps /temp/dev/node_modules node_modules
|
|
|
|
COPY web .
|
2023-09-24 19:18:39 +00:00
|
|
|
|
2023-11-02 13:02:33 +00:00
|
|
|
# build
|
2023-09-24 19:18:39 +00:00
|
|
|
ENV NODE_ENV=production
|
2023-11-07 22:06:32 +00:00
|
|
|
RUN npm run build
|
2023-09-24 19:18:39 +00:00
|
|
|
|
|
|
|
|
2023-11-02 13:02:33 +00:00
|
|
|
FROM base AS release
|
2023-09-24 19:18:39 +00:00
|
|
|
|
2023-11-02 13:02:33 +00:00
|
|
|
COPY --from=deps /temp/prod/node_modules node_modules
|
2023-11-07 20:12:06 +00:00
|
|
|
COPY --from=build /app/build build
|
2023-11-05 16:20:21 +00:00
|
|
|
COPY --from=build /app/package.json .
|
2023-09-24 19:18:39 +00:00
|
|
|
|
2023-11-02 13:02:33 +00:00
|
|
|
ENV NODE_ENV=production
|
2023-12-19 09:51:23 +00:00
|
|
|
ENV LOG_LEVEL=error
|
2023-09-24 19:18:39 +00:00
|
|
|
|
2023-12-10 23:20:54 +00:00
|
|
|
COPY docker-entrypoint.sh /entrypoint.sh
|
|
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
2023-11-05 16:20:21 +00:00
|
|
|
|
2023-11-07 19:01:12 +00:00
|
|
|
HEALTHCHECK --interval=60s --timeout=3s --start-period=20s --retries=3 \
|
|
|
|
CMD curl -f http://127.0.0.1:3000/api/health || exit 1
|
|
|
|
|
2023-12-11 00:36:15 +00:00
|
|
|
RUN mkdir -p /data && chmod 700 /data
|
|
|
|
RUN mkdir -p /etc/torrc.d && chmod -R 400 /etc/torrc.d
|
2023-12-19 09:51:23 +00:00
|
|
|
RUN mkdir -p /var/vlogs && chmod -R 600 /var/vlogs && touch /var/vlogs/web
|
2023-12-11 00:36:15 +00:00
|
|
|
|
2023-12-19 05:00:54 +00:00
|
|
|
VOLUME ["/etc/torrc.d", "/data", "/var/vlogs"]
|
2023-12-10 23:20:54 +00:00
|
|
|
|
2023-11-02 13:02:33 +00:00
|
|
|
# run the app
|
2023-09-24 19:18:39 +00:00
|
|
|
EXPOSE 3000/tcp
|
2023-11-07 20:12:06 +00:00
|
|
|
CMD [ "npm", "run", "start" ]
|