updated to be pure alpine and nginx on top of it
This commit is contained in:
37
Dockerfile
37
Dockerfile
@@ -1,31 +1,26 @@
|
||||
# Build stage
|
||||
FROM alpine:3.22 AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
RUN apk add --no-cache build-base
|
||||
|
||||
# Build if needed
|
||||
COPY . .
|
||||
RUN make build
|
||||
|
||||
# Runtime stage
|
||||
FROM alpine:3.22
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
RUN apk add --no‑cache nginx
|
||||
|
||||
# Create non root user and group
|
||||
RUN addgroup -S zxc && \
|
||||
adduser -S appuser -G zxc
|
||||
RUN addgroup -S webgroup && \
|
||||
adduser -S webuser -G webgroup
|
||||
|
||||
# Copy from builder
|
||||
COPY --from=builder /app/mybinary /app/mybinary
|
||||
# Workdir
|
||||
RUN mkdir /usr/share/nginx/root
|
||||
WORKDIR /usr/share/nginx/root
|
||||
|
||||
# Set ownership
|
||||
RUN chown zxc:zxc /app/mybinary
|
||||
# Make / Set ownership and premission
|
||||
RUN chown -R webuser:webgroup /usr/share/nginx/root /var/cache/nginx /var/log/nginx
|
||||
RUN chmod 750 /usr/share/nginx/root
|
||||
|
||||
USER appuser
|
||||
# Set non root user
|
||||
USER webuser
|
||||
|
||||
# Open ports
|
||||
EXPOSE 80
|
||||
EXPOSE 80 443
|
||||
|
||||
ENTRYPOINT ["/app/mybinary"]
|
||||
# Start nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Reference in New Issue
Block a user