wireadmin/Dockerfile

91 lines
2.4 KiB
Docker
Raw Permalink Normal View History

2024-02-15 08:16:16 +00:00
ARG ALPINE_VERSION=3.19
2024-05-29 16:40:18 +00:00
ARG LYREBIRD_VERSION=0.2.0
2024-04-01 14:19:30 +00:00
ARG NODE_VERSION=20
2024-05-29 16:40:18 +00:00
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION}-alpine${ALPINE_VERSION} as node
2023-09-24 19:18:39 +00:00
ENV TZ=UTC
2024-05-29 16:40:18 +00:00
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
RUN apk update \
&& apk upgrade \
&& apk add -U --no-cache \
iptables net-tools \
screen logrotate bash \
wireguard-tools \
dnsmasq \
tor \
&& rm -rf /var/cache/apk/*
FROM --platform=${BUILDPLATFORM} golang:alpine AS pluggables
ARG LYREBIRD_VERSION
RUN apk update \
&& apk upgrade \
&& apk add -U --no-cache \
bash \
make \
&& rm -rf /var/cache/apk/*
SHELL ["/bin/bash", "-c"]
RUN <<EOT
set -ex
cd /tmp
# Lyrebird - https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird
wget "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/-/archive/lyrebird-$LYREBIRD_VERSION/lyrebird-lyrebird-$LYREBIRD_VERSION.tar.gz"
tar -xvf lyrebird-lyrebird-$LYREBIRD_VERSION.tar.gz
pushd lyrebird-lyrebird-$LYREBIRD_VERSION || exit 1
make build -e VERSION=$LYREBIRD_VERSION
cp ./lyrebird /usr/local/bin
popd || exit 1
cp -rv /go/bin /usr/local/bin
rm -rf /go
rm -rf /tmp/*
EOT
FROM node AS build
WORKDIR /app
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
2023-11-02 13:02:33 +00:00
COPY web .
2023-12-19 11:25:45 +00:00
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile \
2024-05-29 16:40:18 +00:00
&& NODE_ENV=production pnpm build \
&& pnpm prune --prod \
&& cp -R node_modules build package.json /tmp \
&& rm -rf ./*
2023-09-24 19:18:39 +00:00
2024-05-29 16:40:18 +00:00
FROM node
WORKDIR /app
2023-09-24 19:18:39 +00:00
2024-05-29 16:40:18 +00:00
COPY --from=pluggables /usr/local/bin/lyrebird /usr/local/bin/lyrebird
COPY rootfs /
2023-09-24 19:18:39 +00:00
2024-05-29 16:40:18 +00:00
ENV PROTOCOL_HEADER=x-forwarded-proto
ENV HOST_HEADER=x-forwarded-host
ENV NODE_ENV=production
ENV LOG_LEVEL=error
# Copy the goodies from the build stage
COPY --from=build /tmp/package.json package.json
2023-12-19 11:25:45 +00:00
COPY --from=build /tmp/node_modules node_modules
COPY --from=build /tmp/build build
2023-09-24 19:18:39 +00:00
2024-02-15 08:16:16 +00:00
# Fix permissions
2024-05-29 16:40:18 +00:00
RUN mkdir -p /data/ /etc/tor/torrc.d/ /var/log/wireadmin/ \
&& chmod 700 /data/ \
&& chmod -R 400 /etc/tor/ \
&& touch /var/log/wireadmin/web.log
2024-02-15 08:16:16 +00:00
2024-05-29 16:40:18 +00:00
RUN echo '* * * * * /usr/bin/env logrotate /etc/logrotate.d/rotator' >/etc/crontabs/root
2023-09-24 19:18:39 +00:00
2024-02-12 06:55:37 +00:00
# Setup entrypoint
2023-12-10 23:20:54 +00:00
COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
2024-02-12 06:55:37 +00:00
# Volumes
2024-05-29 16:40:18 +00:00
VOLUME ["/etc/tor", "/var/lib/tor", "/data"]
2024-02-12 06:55:37 +00:00
# Run the app
2023-09-24 19:18:39 +00:00
EXPOSE 3000/tcp
2024-05-29 16:40:18 +00:00
CMD [ "node", "/app/build/index.js" ]