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
|
# Runtime stage
|
||||||
FROM alpine:3.22
|
FROM alpine:3.22
|
||||||
WORKDIR /app
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN apk add --no‑cache nginx
|
||||||
|
|
||||||
# Create non root user and group
|
# Create non root user and group
|
||||||
RUN addgroup -S zxc && \
|
RUN addgroup -S webgroup && \
|
||||||
adduser -S appuser -G zxc
|
adduser -S webuser -G webgroup
|
||||||
|
|
||||||
# Copy from builder
|
# Workdir
|
||||||
COPY --from=builder /app/mybinary /app/mybinary
|
RUN mkdir /usr/share/nginx/root
|
||||||
|
WORKDIR /usr/share/nginx/root
|
||||||
|
|
||||||
# Set ownership
|
# Make / Set ownership and premission
|
||||||
RUN chown zxc:zxc /app/mybinary
|
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
|
# Open ports
|
||||||
EXPOSE 80
|
EXPOSE 80 443
|
||||||
|
|
||||||
ENTRYPOINT ["/app/mybinary"]
|
# Start nginx
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|||||||
Reference in New Issue
Block a user