supports x86_64-musl

This commit is contained in:
Jun Kurihara 2023-01-20 21:34:12 +09:00
commit 9888810b73
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
2 changed files with 16 additions and 24 deletions

View file

@ -1,14 +1,8 @@
FROM ubuntu:22.04 AS base
LABEL maintainer="Jun Kurihara"
SHELL ["/bin/sh", "-x", "-c"]
ENV SERIAL 2
########################################
FROM base as builder
FROM messense/rust-musl-cross:x86_64-musl as builder
ENV TARGET_DIR=x86_64-unknown-linux-musl
ENV CFLAGS=-Ofast
ENV BUILD_DEPS curl make ca-certificates build-essential
WORKDIR /tmp
@ -16,36 +10,34 @@ COPY . /tmp/
ENV RUSTFLAGS "-C link-arg=-s"
RUN update-ca-certificates 2> /dev/null || true
# 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" && \
RUN echo "Building rpxy from source" && \
cargo build --release && \
strip --strip-all /tmp/target/release/rpxy
musl-strip --strip-all /tmp/target/${TARGET_DIR}/release/rpxy
########################################
FROM base AS runner
FROM alpine:latest as runner
ENV TARGET_DIR=x86_64-unknown-linux-musl
ENV RUNTIME_DEPS logrotate ca-certificates
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 &&\
RUN apk add --no-cache ${RUNTIME_DEPS} && \
update-ca-certificates && \
mkdir -p /opt/rpxy/sbin &&\
mkdir -p /var/log/rpxy && \
touch /var/log/rpxy/rpxy.log
COPY --from=builder /tmp/target/release/rpxy /opt/rpxy/sbin/rpxy
COPY --from=builder /tmp/target/${TARGET_DIR}/release/rpxy /opt/rpxy/sbin/rpxy
COPY docker-bin/run.sh /
COPY docker-bin/entrypoint.sh /
RUN chmod 755 /run.sh && \
chmod 755 /entrypoint.sh
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
ENV SSL_CERT_DIR=/etc/ssl/certs
EXPOSE 80 443
CMD ["/entrypoint.sh"]

View file

@ -33,7 +33,7 @@ include /etc/logrotate.d
# system-specific logs may be also be configured here.
EOF
cat > /etc/logrotate.d/rpxy << EOF
cat > /etc/logrotate.d/rpxy.conf << EOF
${LOG_FILE} {
dateext
daily
@ -48,8 +48,8 @@ ${LOG_FILE} {
}
EOF
cp -p /etc/cron.daily/logrotate /etc/cron.hourly/
service cron start
cp -f /etc/periodic/daily/logrotate /etc/periodic/15min
crond restart
# debug level logging
if [ -z $LOG_LEVEL ]; then