changed non root user settings
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0cab77fb37
commit
415e336e62
39
Dockerfile
39
Dockerfile
@ -1,22 +1,29 @@
|
|||||||
# Base-Image
|
# ── Stage 1: Build ───────────────────────────────────────────────────────────
|
||||||
FROM ubuntu:latest
|
FROM gcc:14-bookworm AS builder
|
||||||
|
|
||||||
# Pakete installieren
|
WORKDIR /build
|
||||||
RUN apt-get update
|
COPY deployment.c .
|
||||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
|
||||||
|
|
||||||
# Arbeitsverzeichnis setzen
|
RUN gcc -O2 -static -o deployment deployment.c
|
||||||
|
|
||||||
|
# ── Stage 2: Runtime ─────────────────────────────────────────────────────────
|
||||||
|
FROM alpine:3.21
|
||||||
|
|
||||||
|
# Alle Pakete auf neuesten Stand bringen → patcht libcrypto3/libssl3 auf 3.3.7-r0
|
||||||
|
RUN apk update && apk upgrade --no-cache
|
||||||
|
|
||||||
|
# Nicht-root-User anlegen
|
||||||
|
RUN adduser -D appuser
|
||||||
|
RUN mkdir /output && chown appuser /output
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
COPY --from=builder /build/deployment /app/deployment
|
||||||
|
|
||||||
|
VOLUME [ "/output" ]
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# alles kopieren
|
HEALTHCHECK --interval=30s --timeout=4s --start-period=10s --retries=3 \
|
||||||
COPY . .
|
CMD test -f /output/output.txt && test -s /output/output.txt || exit 1
|
||||||
|
|
||||||
# Code kompilieren
|
ENTRYPOINT ["/bin/sh", "-c"]
|
||||||
RUN gcc -o deployment deployment.c
|
|
||||||
|
|
||||||
# Verzeichnis für Ausgabe anlegen
|
|
||||||
RUN mkdir /output
|
|
||||||
|
|
||||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
|
||||||
ENTRYPOINT ["/bin/bash", "-c"]
|
|
||||||
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||||
22
Dockerfile-alt
Normal file
22
Dockerfile-alt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Base-Image
|
||||||
|
FROM ubuntu:latest
|
||||||
|
|
||||||
|
# Pakete installieren
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install -y build-essential gcc curl vim net-tools
|
||||||
|
|
||||||
|
# Arbeitsverzeichnis setzen
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# alles kopieren
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Code kompilieren
|
||||||
|
RUN gcc -o deployment deployment.c
|
||||||
|
|
||||||
|
# Verzeichnis für Ausgabe anlegen
|
||||||
|
RUN mkdir /output
|
||||||
|
|
||||||
|
# Ausgabe wird ins Container-Dateisystem geschrieben
|
||||||
|
ENTRYPOINT ["/bin/bash", "-c"]
|
||||||
|
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||||
Loading…
x
Reference in New Issue
Block a user