55 lines
1.5 KiB
Docker
55 lines
1.5 KiB
Docker
|
|
FROM ubuntu:22.04 AS base
|
|
LABEL maintainer="Jun Kurihara"
|
|
|
|
SHELL ["/bin/sh", "-x", "-c"]
|
|
ENV SERIAL 2
|
|
|
|
########################################
|
|
FROM base as builder
|
|
|
|
ENV CFLAGS=-Ofast
|
|
ENV BUILD_DEPS curl make ca-certificates build-essential
|
|
|
|
WORKDIR /tmp
|
|
|
|
COPY . /tmp/
|
|
|
|
ENV RUSTFLAGS "-C link-arg=-s"
|
|
|
|
RUN update-ca-certificates 2> /dev/null || true
|
|
|
|
RUN apt-get update && apt-get install -qy --no-install-recommends $BUILD_DEPS && \
|
|
curl -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain stable && \
|
|
export PATH="$HOME/.cargo/bin:$PATH" && \
|
|
echo "Building rpxy from source" && \
|
|
cargo build --release && \
|
|
strip --strip-all /tmp/target/release/rpxy
|
|
|
|
########################################
|
|
FROM base AS runner
|
|
|
|
ENV RUNTIME_DEPS logrotate ca-certificates gosu
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -qy --no-install-recommends $RUNTIME_DEPS && \
|
|
apt-get -qy clean && \
|
|
apt-get -qy autoremove && \
|
|
rm -fr /tmp/* /var/tmp/* /var/cache/apt/* /var/lib/apt/lists/* /var/log/apt/* /var/log/*.log && \
|
|
find / -type d -path /proc -prune -o -type f -perm /u+s -ignore_readdir_race -exec chmod u-s {} \; && \
|
|
find / -type d -path /proc -prune -o -type f -perm /g+s -ignore_readdir_race -exec chmod g-s {} \; && \
|
|
mkdir -p /rpxy/bin &&\
|
|
mkdir -p /rpxy/log
|
|
|
|
COPY --from=builder /tmp/target/release/rpxy /rpxy/bin/rpxy
|
|
COPY ./docker/run.sh /rpxy
|
|
COPY ./docker/entrypoint.sh /rpxy
|
|
|
|
RUN chmod +x /rpxy/run.sh && \
|
|
chmod +x /rpxy/entrypoint.sh
|
|
|
|
EXPOSE 80 443
|
|
|
|
CMD ["/usr/bin/bash" "/rpxy/entrypoint.sh"]
|
|
|
|
ENTRYPOINT ["/usr/bin/bash", "/rpxy/entrypoint.sh"]
|