|
@@ -1,35 +1,53 @@
|
|
-####################################################
|
|
|
|
-# build stage
|
|
|
|
-####################################################
|
|
|
|
|
|
+# ---------------------------------------------------
|
|
|
|
+# Build Stage
|
|
|
|
+# ---------------------------------------------------
|
|
|
|
|
|
|
|
+# Use Alpine Linux 3.18 as the base image for the build stage
|
|
FROM alpine:3.18 AS build
|
|
FROM alpine:3.18 AS build
|
|
|
|
+
|
|
|
|
+# Update package list and install build dependencies
|
|
RUN apk update && \
|
|
RUN apk update && \
|
|
apk add --no-cache \
|
|
apk add --no-cache \
|
|
build-base zlib-dev
|
|
build-base zlib-dev
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+# Set the working directory inside the container
|
|
WORKDIR /civetweb
|
|
WORKDIR /civetweb
|
|
|
|
+
|
|
|
|
+# Copy source code and other necessary files into the container
|
|
COPY src ./src/
|
|
COPY src ./src/
|
|
COPY include ./include/
|
|
COPY include ./include/
|
|
COPY Makefile ./
|
|
COPY Makefile ./
|
|
COPY resources ./resources/
|
|
COPY resources ./resources/
|
|
COPY *.md ./
|
|
COPY *.md ./
|
|
|
|
|
|
|
|
+# Build Civetweb with all features and install it into /app directory
|
|
RUN make build && \
|
|
RUN make build && \
|
|
make WITH_ALL=1 && \
|
|
make WITH_ALL=1 && \
|
|
make install PREFIX=/app
|
|
make install PREFIX=/app
|
|
|
|
|
|
-####################################################
|
|
|
|
-# image stage
|
|
|
|
-####################################################
|
|
|
|
|
|
+# ---------------------------------------------------
|
|
|
|
+# Image Stage
|
|
|
|
+# ---------------------------------------------------
|
|
|
|
|
|
|
|
+# Use Alpine Linux 3.18 as the base image for the final stage
|
|
FROM alpine:3.18
|
|
FROM alpine:3.18
|
|
|
|
+
|
|
|
|
+# Update package list and install runtime dependencies
|
|
RUN apk update && \
|
|
RUN apk update && \
|
|
apk add --no-cache \
|
|
apk add --no-cache \
|
|
libstdc++ zlib
|
|
libstdc++ zlib
|
|
|
|
|
|
|
|
+# Create a non-root user and group for running Civetweb
|
|
RUN addgroup -S civetweb && adduser -S civetweb -G civetweb
|
|
RUN addgroup -S civetweb && adduser -S civetweb -G civetweb
|
|
|
|
+
|
|
|
|
+# Switch to the non-root user
|
|
USER civetweb
|
|
USER civetweb
|
|
|
|
|
|
|
|
+# Copy the built application from the build stage into this stage
|
|
COPY --chown=civetweb:civetweb --from=build /app/ /app/
|
|
COPY --chown=civetweb:civetweb --from=build /app/ /app/
|
|
|
|
|
|
|
|
+# Expose port 8080 for the application
|
|
|
|
+EXPOSE 8080
|
|
|
|
+
|
|
|
|
+# Set the entry point for the container
|
|
ENTRYPOINT [ "/app/bin/civetweb", "/app/etc/civetweb.conf" ]
|
|
ENTRYPOINT [ "/app/bin/civetweb", "/app/etc/civetweb.conf" ]
|