forked from civetweb/civetweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
53 lines (40 loc) · 1.49 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# ---------------------------------------------------
# Build Stage
# ---------------------------------------------------
# Use Alpine Linux 3.18 as the base image for the build stage
FROM alpine:3.18 AS build
# Update package list and install build dependencies
RUN apk update && \
apk add --no-cache \
build-base zlib-dev
# Set the working directory inside the container
WORKDIR /civetweb
# Copy source code and other necessary files into the container
COPY src ./src/
COPY include ./include/
COPY Makefile ./
COPY resources ./resources/
COPY *.md ./
# Build Civetweb with all features and install it into /app directory
RUN make build && \
make WITH_ALL=1 && \
make install PREFIX=/app
# ---------------------------------------------------
# Image Stage
# ---------------------------------------------------
# Use Alpine Linux 3.18 as the base image for the final stage
FROM alpine:3.18
# Update package list and install runtime dependencies
RUN apk update && \
apk add --no-cache \
libstdc++ zlib
# Create a non-root user and group for running Civetweb
RUN addgroup -S civetweb && adduser -S civetweb -G civetweb
# Switch to the non-root user
USER civetweb
# Copy the built application from the build stage into this stage
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" ]