forked from freudenreichan/EinfuehrungInDocker_Pipeline2
Compare commits
No commits in common. "main" and "main" have entirely different histories.
@ -1,5 +1,2 @@
|
|||||||
.git
|
.git
|
||||||
.drone.yml
|
.gitignore
|
||||||
README.md
|
|
||||||
*.tar
|
|
||||||
*.tar.gz
|
|
||||||
32
.drone.yml
32
.drone.yml
@ -32,38 +32,36 @@ steps:
|
|||||||
|
|
||||||
- name: push-artifact
|
- name: push-artifact
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
#environment:
|
environment:
|
||||||
#GITEA_TOKEN:
|
GITEA_TOKEN:
|
||||||
#from_secret: GITEA_TOKEN
|
from_secret: GITEA_TOKEN
|
||||||
commands:
|
commands:
|
||||||
- ls -lh image.tar
|
- apk add --no-cache git
|
||||||
- echo "Artifact image.tar wurde erfolgreich erzeugt."
|
|
||||||
#- apk add --no-cache git
|
|
||||||
|
|
||||||
# Git konfigurieren
|
# Git konfigurieren
|
||||||
#- git config --global user.email "drone@ci.local"
|
- git config --global user.email "drone@ci.local"
|
||||||
#- git config --global user.name "Drone CI"
|
- git config --global user.name "Drone CI"
|
||||||
|
|
||||||
# Remote setzen
|
# Remote setzen
|
||||||
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
||||||
|
|
||||||
# Repo clonen
|
# Repo clonen
|
||||||
#- git clone https://oauth2:${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/schrammlu92345/EinfuehrungInDocker_Pipeline2.git
|
- git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
|
||||||
#- cd EinfuehrungInDocker_Pipeline2
|
- cd EinfuehrungInDocker_Pipeline
|
||||||
|
|
||||||
# Branch wechseln oder erstellen
|
# Branch wechseln oder erstellen
|
||||||
#- git checkout drone-artifacts || git checkout -b drone-artifacts
|
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
||||||
|
|
||||||
# Artifact löschen und neu hinzufügen
|
# Artifact löschen und neu hinzufügen
|
||||||
#- git rm -f image.tar || true
|
- git rm image.tar
|
||||||
#- cp /drone/src/image.tar .
|
- cp $DRONE_WORKSPACE/image.tar .
|
||||||
#- git add image.tar
|
- git add image.tar
|
||||||
|
|
||||||
# Commit nur wenn Änderungen vorhanden
|
# Commit nur wenn Änderungen vorhanden
|
||||||
#- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
|
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
|
||||||
|
|
||||||
# Pull vor Push (um Konflikte zu vermeiden)
|
# Pull vor Push (um Konflikte zu vermeiden)
|
||||||
#- git pull || true
|
- git pull || true
|
||||||
|
|
||||||
# Push
|
# Push
|
||||||
#- git push https://oauth2:${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/schrammlu92345/EinfuehrungInDocker_Pipeline2.git drone-artifacts
|
- git push
|
||||||
39
Dockerfile
39
Dockerfile
@ -1,33 +1,22 @@
|
|||||||
FROM alpine:3.23 AS builder
|
# Base-Image
|
||||||
|
FROM ubuntu:latest
|
||||||
|
|
||||||
RUN apk upgrade --no-cache && apk add --no-cache gcc musl-dev
|
# Pakete installieren
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install -y build-essential gcc curl vim net-tools
|
||||||
|
|
||||||
|
# Arbeitsverzeichnis setzen
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# alles kopieren
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN gcc -O2 -o deployment deployment.c
|
# Code kompilieren
|
||||||
|
RUN gcc -o deployment deployment.c
|
||||||
|
|
||||||
|
# Verzeichnis für Ausgabe anlegen
|
||||||
|
RUN mkdir /output
|
||||||
|
|
||||||
FROM alpine:3.23
|
# Ausgabe wird ins Container-Dateisystem geschrieben
|
||||||
|
ENTRYPOINT ["/bin/bash", "-c"]
|
||||||
RUN apk upgrade --no-cache
|
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY --from=builder /app/deployment /app/deployment
|
|
||||||
|
|
||||||
RUN addgroup -S appuser \
|
|
||||||
&& adduser -S appuser -G appuser \
|
|
||||||
&& mkdir /output \
|
|
||||||
&& chown -R appuser:appuser /app /output
|
|
||||||
|
|
||||||
VOLUME ["/output"]
|
|
||||||
|
|
||||||
USER appuser
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
||||||
CMD test -s /output/output.txt || exit 1
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/sh", "-c"]
|
|
||||||
CMD ["./deployment 10 2>&1 | tee /output/output.txt"]
|
|
||||||
Loading…
x
Reference in New Issue
Block a user