redlib/Dockerfile

37 lines
1 KiB
Text
Raw Normal View History

# Use an Alpine-based image as the base
FROM rust:1.71.0-alpine3.19 AS build
2021-04-09 15:24:47 -07:00
# Install necessary dependencies (git, curl, etc.)
RUN apk add --no-cache git curl build-base
2021-04-09 15:24:47 -07:00
# Set the working directory for the build process
WORKDIR /build
2024-11-29 00:09:36 -08:00
# Clone the repository
RUN git clone https://github.com/LucifersCircle/redlib.git .
# Build the project using Cargo
RUN cargo build --release
2024-11-29 00:09:36 -08:00
# Final image with only the necessary runtime dependencies
FROM alpine:3.19
# Install dependencies needed to run the binary (curl, for healthcheck)
RUN apk add --no-cache curl
# Copy the compiled binary from the build stage
COPY --from=build /build/target/release/redlib /usr/local/bin/
# Add a 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 01:15:03 -08:00
# Expose the necessary port
EXPOSE 8080
2021-04-09 15:24:47 -07:00
# Run a healthcheck to ensure the app is working
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider -q http://localhost:8080/settings || exit 1
# Set the default command to run the redlib binary
CMD ["redlib"]