-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (42 loc) · 1.24 KB
/
Dockerfile
File metadata and controls
57 lines (42 loc) · 1.24 KB
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
54
55
56
57
# Multi-stage build for webfsd
FROM alpine:3.19 AS builder
# Install build dependencies
RUN apk add --no-cache \
build-base \
make \
openssl-dev \
linux-headers
# Create working directory
WORKDIR /src
# Copy source code
COPY . .
# Build webfsd
RUN make clean && make
# Test the binary works
RUN ./webfsd -h
# Runtime stage
FROM alpine:3.19
# Install runtime dependencies
RUN apk add --no-cache \
openssl \
ca-certificates \
&& addgroup -g 1000 webfsd \
&& adduser -D -u 1000 -G webfsd webfsd
# Copy the binary from builder stage
COPY --from=builder /src/webfsd /usr/local/bin/webfsd
# Create directory for web content
RUN mkdir -p /var/www && chown webfsd:webfsd /var/www
# Create a simple index.html for testing
RUN echo '<html><body><h1>webfsd is running!</h1><p>Lightweight HTTP server</p></body></html>' > /var/www/index.html \
&& chown webfsd:webfsd /var/www/index.html
# Switch to non-root user
USER webfsd
# Set working directory to web content
WORKDIR /var/www
# Expose port 8000
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8000/ || exit 1
# Default command
CMD ["webfsd", "-p", "8000", "-F"]