redlib/Dockerfile

36 lines
1 KiB
Text
Raw Normal View History

2024-11-29 01:12:34 -08:00
FROM rust:1.71.0-alpine
2021-04-09 15:24:47 -07:00
# Set the target architecture as an ARG (default to x86_64)
ARG TARGET=x86_64-unknown-linux-musl
2021-04-09 15:24:47 -07:00
# Install dependencies (curl, make, cmake, etc.)
RUN apk add --no-cache curl cmake make
2021-04-09 15:24:47 -07:00
# Create the working directory for the build process
WORKDIR /build
2024-11-29 00:09:36 -08:00
# Clone the redlib repository
RUN git clone https://github.com/LucifersCircle/redlib.git /build
# Checkout the main branch
RUN cd /build && git checkout main
2024-11-29 00:09:36 -08:00
# Build the redlib binary using cargo
RUN cd /build && cargo build --release --target ${TARGET}
2024-11-29 00:26:45 -08:00
# Copy the binary to the appropriate location
RUN cp /build/target/${TARGET}/release/redlib /usr/local/bin/redlib
2024-11-29 00:09:36 -08:00
# Set up a non-privileged user to run the binary
2023-12-26 18:25:52 -05:00
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
USER redlib
2021-04-09 15:24:47 -07:00
# Expose port 8080
EXPOSE 8080
2021-04-09 15:24:47 -07:00
2024-11-29 00:25:20 -08:00
# 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
2021-04-01 12:09:08 -07:00
# Command to run the binary
CMD ["redlib"]