2024-11-29 00:26:45 -08:00
|
|
|
# Use the official Rust image with Alpine base
|
|
|
|
FROM rust:alpine
|
2021-04-09 15:24:47 -07:00
|
|
|
|
2024-11-29 00:25:20 -08:00
|
|
|
# Set the target architecture as an ARG
|
2024-11-29 00:18:32 -08:00
|
|
|
ARG TARGET
|
2021-04-09 15:24:47 -07:00
|
|
|
|
2024-11-29 00:25:20 -08:00
|
|
|
# Install necessary dependencies for building (including git)
|
|
|
|
RUN apk add --no-cache curl git build-base
|
2021-04-09 15:24:47 -07:00
|
|
|
|
2024-11-29 00:25:20 -08:00
|
|
|
# Clone the repository into /redlib
|
|
|
|
RUN git clone https://github.com/LucifersCircle/redlib.git /redlib
|
2024-11-29 00:09:36 -08:00
|
|
|
|
2024-11-29 00:25:20 -08:00
|
|
|
# Set the working directory to the root of the cloned repository
|
|
|
|
WORKDIR /redlib
|
2024-11-29 00:18:32 -08:00
|
|
|
|
2024-11-29 00:25:20 -08:00
|
|
|
# Checkout the main branch (if needed)
|
|
|
|
RUN git checkout main
|
2024-11-29 00:09:36 -08:00
|
|
|
|
2024-11-29 00:26:45 -08:00
|
|
|
# Install the desired version of Rust (if a specific version is needed)
|
|
|
|
RUN rustup install stable
|
|
|
|
RUN rustup default stable
|
|
|
|
|
2024-11-29 00:25:20 -08:00
|
|
|
# Build the project using Cargo (this will handle the Rust-specific build)
|
|
|
|
RUN cargo build --release --target ${TARGET}
|
2024-11-29 00:09:36 -08:00
|
|
|
|
2024-11-29 00:25:20 -08:00
|
|
|
# Create a non-root user to run the application
|
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
|
|
|
|
2024-11-29 00:25:20 -08:00
|
|
|
# Expose the application port (if applicable)
|
2021-02-24 20:17:36 +01:00
|
|
|
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
|
2024-05-31 11:40:01 +02:00
|
|
|
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider -q http://localhost:8080/settings || exit 1
|
2021-04-01 12:09:08 -07:00
|
|
|
|
2024-11-29 00:25:20 -08:00
|
|
|
# Default command to run the application
|
|
|
|
CMD ["./target/${TARGET}/release/redlib"]
|