This commit is contained in:
parent
94a0971633
commit
a9c15abdb1
72
.gitea/workflows/docker-build.yml
Normal file
72
.gitea/workflows/docker-build.yml
Normal file
@ -0,0 +1,72 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: docker
|
||||
|
||||
steps:
|
||||
- name: Install Docker CLI
|
||||
run: |
|
||||
wget -q https://download.docker.com/linux/static/stable/x86_64/docker-25.0.3.tgz
|
||||
tar xzf docker-25.0.3.tgz --strip-components=1 -C /usr/local/bin docker/docker
|
||||
rm docker-25.0.3.tgz
|
||||
docker --version
|
||||
|
||||
- name: Clone repository
|
||||
run: |
|
||||
apk add --no-cache git || apt-get update && apt-get install -y git
|
||||
cd /workspace/szmyt151
|
||||
rm -rf szmyt151-web || true
|
||||
git clone --depth 1 --branch ${GITHUB_REF##*/} https://git.szmyt151.pl/szmyt151/szmyt151-web.git
|
||||
cd szmyt151-web
|
||||
ls -la
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
cd /workspace/szmyt151/szmyt151-web
|
||||
docker build -t registry.szmyt151.pl/registryuser/szmyt151-web:latest .
|
||||
docker tag registry.szmyt151.pl/registryuser/szmyt151-web:latest registry.szmyt151.pl/registryuser/szmyt151-web:$GITHUB_SHA
|
||||
|
||||
- name: Login to Docker Registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login registry.szmyt151.pl -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin
|
||||
|
||||
- name: Push Docker image
|
||||
run: |
|
||||
docker push registry.szmyt151.pl/registryuser/szmyt151-web:latest
|
||||
docker push registry.szmyt151.pl/registryuser/szmyt151-web:$GITHUB_SHA
|
||||
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: |
|
||||
docker logout registry.szmyt151.pl || true
|
||||
|
||||
- name: List all containers (verify access)
|
||||
run: |
|
||||
echo "=== All containers on host ==="
|
||||
docker ps -a
|
||||
|
||||
- name: Deploy (reload container)
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login registry.szmyt151.pl -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin
|
||||
docker pull registry.szmyt151.pl/registryuser/szmyt151-web:latest
|
||||
docker stop szmyt151-web || true
|
||||
docker rm szmyt151-web || true
|
||||
docker run -d \
|
||||
--name szmyt151-web \
|
||||
-p 8080:80 \
|
||||
-v szmyt151-web-vendor:/var/www/html/vendor \
|
||||
--restart unless-stopped \
|
||||
registry.szmyt151.pl/registryuser/szmyt151-web:latest
|
||||
docker logout registry.szmyt151.pl
|
||||
echo "Container deployed successfully"
|
||||
Loading…
Reference in New Issue
Block a user