redlib/Dockerfile

43 lines
1 KiB
Text
Raw Normal View History

FROM alpine:3.19
2021-04-09 15:24:47 -07:00
# Set build arguments
ARG TARGET
2024-11-29 00:09:36 -08:00
ARG BUILD_DIR=/build
2021-04-09 15:24:47 -07:00
# Install required dependencies
RUN apk add --no-cache \
curl \
git \
build-base \
cmake
2021-04-09 15:24:47 -07:00
# Clone the repository and checkout the main branch
RUN git clone https://github.com/LucifersCircle/redlib.git ${BUILD_DIR} && \
cd ${BUILD_DIR} && \
git checkout main
2024-11-29 00:09:36 -08:00
# Build the project
2024-11-29 00:09:36 -08:00
WORKDIR ${BUILD_DIR}
# Run cmake to configure and make to build the project
2024-11-29 00:09:36 -08:00
RUN cmake -DCMAKE_BUILD_TYPE=Release -DTARGET=${TARGET} . && \
make
# Move the compiled binary to /usr/local/bin
RUN mv ${BUILD_DIR}/target/${TARGET}/redlib /usr/local/bin/redlib
# Clean up build dependencies
RUN apk del build-base cmake && rm -rf ${BUILD_DIR}
2020-10-25 13:48:44 -07:00
# Add a non-root user for security
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
# Healthcheck to ensure 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
CMD ["redlib"]