0
0
docker-images/dockerfiles/redlib.Dockerfile

39 lines
1.2 KiB
Docker
Raw Normal View History

2024-10-09 07:04:17 +08:00
# Stage 1: Build the redlib binary
FROM rust:alpine3.19 AS builder
ARG TARGET=aarch64-unknown-linux-musl
# Install necessary packages for building the application
RUN apk add --no-cache curl git musl-dev
# Clone the redlib repository and build
RUN git clone https://github.com/redlib-org/redlib && \
cd redlib && \
sed -i 's/#9a0000/#4385BE/g' static/themes/light.css && \
sed -i 's/#9a0000/#205EA6/g' static/themes/black.css && \
sed -i 's/red/#205EA6/g' static/themes/dark.css && \
cargo build --release --target=${TARGET} && \
cp target/${TARGET}/release/redlib /usr/local/bin/redlib && \
cd .. && \
rm -rf redlib
# Stage 2: Create the final image
FROM alpine:3.19
RUN apk add --no-cache curl
# Create a non-root user
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
# Copy the compiled binary from the builder stage
COPY --from=builder /usr/local/bin/redlib /usr/local/bin/redlib
# Tell Docker to expose port 8080
EXPOSE 8080
# Run a healthcheck every minute to make sure redlib is functional
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider -q http://localhost:8080/settings || exit 1
USER redlib
CMD ["redlib"]