diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..78e2adc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.12-slim + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY app.py . +COPY templates ./templates +COPY static ./static + +EXPOSE 5000 + +CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..83d3ce5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,54 @@ +pipeline { + agent any + + environment { + REGISTRY = "gitea.yourdomain.com" + IMAGE = "gitea.yourdomain.com//work-week-progress" + TAG = "${env.BUILD_NUMBER}" + } + + stages { + stage("Checkout") { + steps { + checkout scm + } + } + + stage("Build Image") { + steps { + sh """ + docker build \ + -t ${IMAGE}:${TAG} \ + -t ${IMAGE}:latest \ + . + """ + } + } + + stage("Push Image") { + steps { + withCredentials([ + usernamePassword( + credentialsId: 'gitea-registry-creds', + usernameVariable: 'GITEA_USER', + passwordVariable: 'GITEA_TOKEN' + ) + ]) { + sh """ + echo "$GITEA_TOKEN" | docker login ${REGISTRY} \ + -u "$GITEA_USER" --password-stdin + + docker push ${IMAGE}:${TAG} + docker push ${IMAGE}:latest + """ + } + } + } + } + + post { + cleanup { + sh "docker image prune -f" + } + } +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e4a286c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +gunicorn