Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7eaab444c | |||
| 09f88c1463 | |||
| b970119a33 | |||
| d517a3ac81 | |||
| f325e6922e | |||
| d0c0343a4d |
@ -1,2 +1,5 @@
|
||||
.git
|
||||
.gitignore
|
||||
.drone.yml
|
||||
README.md
|
||||
*.tar
|
||||
*.tar.gz
|
||||
|
||||
32
.drone.yml
32
.drone.yml
@ -32,36 +32,38 @@ steps:
|
||||
|
||||
- name: push-artifact
|
||||
image: alpine:latest
|
||||
environment:
|
||||
GITEA_TOKEN:
|
||||
from_secret: GITEA_TOKEN
|
||||
#environment:
|
||||
#GITEA_TOKEN:
|
||||
#from_secret: GITEA_TOKEN
|
||||
commands:
|
||||
- apk add --no-cache git
|
||||
- ls -lh image.tar
|
||||
- echo "Artifact image.tar wurde erfolgreich erzeugt."
|
||||
#- apk add --no-cache git
|
||||
|
||||
# Git konfigurieren
|
||||
- git config --global user.email "drone@ci.local"
|
||||
- git config --global user.name "Drone CI"
|
||||
#- git config --global user.email "drone@ci.local"
|
||||
#- git config --global user.name "Drone CI"
|
||||
|
||||
# Remote setzen
|
||||
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
||||
|
||||
# Repo clonen
|
||||
- git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
|
||||
- cd EinfuehrungInDocker_Pipeline
|
||||
#- git clone https://oauth2:${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/schrammlu92345/EinfuehrungInDocker_Pipeline2.git
|
||||
#- cd EinfuehrungInDocker_Pipeline2
|
||||
|
||||
# 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
|
||||
- git rm image.tar
|
||||
- cp $DRONE_WORKSPACE/image.tar .
|
||||
- git add image.tar
|
||||
#- git rm -f image.tar || true
|
||||
#- cp /drone/src/image.tar .
|
||||
#- git add image.tar
|
||||
|
||||
# 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)
|
||||
- git pull || true
|
||||
#- git pull || true
|
||||
|
||||
# Push
|
||||
- git push
|
||||
#- git push https://oauth2:${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/schrammlu92345/EinfuehrungInDocker_Pipeline2.git drone-artifacts
|
||||
|
||||
39
Dockerfile
39
Dockerfile
@ -1,22 +1,33 @@
|
||||
# Base-Image
|
||||
FROM ubuntu:latest
|
||||
FROM alpine:3.23 AS builder
|
||||
|
||||
# Pakete installieren
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
||||
RUN apk upgrade --no-cache && apk add --no-cache gcc musl-dev
|
||||
|
||||
# Arbeitsverzeichnis setzen
|
||||
WORKDIR /app
|
||||
|
||||
# alles kopieren
|
||||
COPY . .
|
||||
|
||||
# Code kompilieren
|
||||
RUN gcc -o deployment deployment.c
|
||||
RUN gcc -O2 -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"]
|
||||
FROM alpine:3.23
|
||||
|
||||
RUN apk upgrade --no-cache
|
||||
|
||||
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