forked from freudenreichan/EinfuehrungInDocker_Pipeline2
Some checks reported errors
continuous-integration/drone/push Build encountered an error
38 lines
777 B
Docker
38 lines
777 B
Docker
# Base-Image - Alpine statt Ubuntu
|
|
FROM alpine:latest AS build
|
|
|
|
# Build-Tools installieren
|
|
RUN apk add --no-cache gcc musl-dev
|
|
|
|
# Arbeitsverzeichnis setzen
|
|
WORKDIR /app
|
|
|
|
# Code kopieren und kompilieren
|
|
COPY deployment.c .
|
|
RUN gcc -o deployment deployment.c
|
|
|
|
# Finales schlankes Image
|
|
FROM alpine:latest
|
|
|
|
# Nicht als root laufen
|
|
RUN adduser -D appuser
|
|
|
|
WORKDIR /app
|
|
|
|
# Nur das Binary kopieren
|
|
COPY --from=build /app/deployment .
|
|
|
|
# Ausgabeverzeichnis anlegen und Rechte setzen
|
|
RUN mkdir /output && chown appuser /output
|
|
|
|
# Volume für Ausgabe
|
|
VOLUME /output
|
|
|
|
# User wechseln
|
|
USER appuser
|
|
|
|
# Healthcheck
|
|
HEALTHCHECK --interval=30s --timeout=5s CMD pgrep deployment || exit 1
|
|
|
|
ENTRYPOINT ["/bin/sh", "-c"]
|
|
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"] |