From 82917f92140fed3109e732afac7eeaf1d9116a67 Mon Sep 17 00:00:00 2001 From: LucifersCircle Date: Fri, 29 Nov 2024 00:18:32 -0800 Subject: [PATCH] Update Dockerfile Try cloning repo for build and transfer --- Dockerfile | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 26d0560..654ece2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,25 @@ FROM alpine:3.19 -ARG TARGET=x86_64-unknown-linux-musl +# Set build arguments +ARG TARGET ARG BUILD_DIR=/build -RUN apk add --no-cache curl build-base cmake +# Install required dependencies +RUN apk add --no-cache \ + curl \ + git \ + build-base \ + cmake -# Download the latest source code from the main branch -RUN mkdir -p ${BUILD_DIR} && \ - curl -L "https://github.com/LucifersCircle/redlib/archive/refs/heads/main.tar.gz" | \ - tar --strip-components=1 -xz -C ${BUILD_DIR} +# 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 -# Build the binary +# Build the project WORKDIR ${BUILD_DIR} + +# Run cmake to configure and make to build the project RUN cmake -DCMAKE_BUILD_TYPE=Release -DTARGET=${TARGET} . && \ make @@ -21,11 +29,14 @@ 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} +# Add a non-root user for security RUN adduser --home /nonexistent --no-create-home --disabled-password redlib USER redlib +# Expose port 8080 EXPOSE 8080 +# Healthcheck to ensure redlib is functional HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider -q http://localhost:8080/settings || exit 1 CMD ["redlib"]