94 lines
3.2 KiB
YAML
94 lines
3.2 KiB
YAML
name: build-docker-images-for-latest-release-github-ver
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# # Cache Docker layers
|
|
# - name: Cache Docker image layers
|
|
# uses: http://fly6516.synology.me:4000/Gitea_Action/cache@v3
|
|
# with:
|
|
# path: /tmp/.buildkit-cache
|
|
# key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}
|
|
# restore-keys: |
|
|
# ${{ runner.os }}-docker-
|
|
|
|
# Checkout the repository
|
|
- name: Checkout repository
|
|
uses: http://fly6516.synology.me:4000/Gitea_Action/checkout@v2
|
|
|
|
# pre pull image
|
|
- name: Pre Pull Image if Needed
|
|
run: |
|
|
IMAGE_NAME="dockerp.com/moby/buildkit:buildx-stable-1"
|
|
if ! docker image inspect "$IMAGE_NAME" > /dev/null 2>&1; then
|
|
echo "Image does not exist locally. Pulling..."
|
|
docker pull "$IMAGE_NAME"
|
|
else
|
|
echo "Image already exists locally."
|
|
fi
|
|
|
|
# Create Docker configuration directory
|
|
- name: Create Docker configuration directory
|
|
run: sudo mkdir -p /etc/docker
|
|
|
|
# # Configure Docker to use dockerp.com as a mirror
|
|
# - name: Configure Docker Daemon for Mirror
|
|
# run: |
|
|
# echo '{
|
|
# "registry-mirrors": ["https://dockerp.com"]
|
|
# }' | sudo tee /etc/docker/daemon.json
|
|
#
|
|
# # Restart Docker Daemon Without systemd
|
|
# - name: Restart Docker Daemon
|
|
# run: |
|
|
# sudo chmod 644 /etc/docker/daemon.json
|
|
# sudo pkill -f dockerd || true
|
|
# sudo pkill -f docker || true
|
|
# sudo nohup dockerd > /dev/null 2>&1 &
|
|
# sudo nohup docker > /dev/null 2>&1 &
|
|
# sleep 5
|
|
#
|
|
# # Validate Docker Configuration
|
|
# - name: Validate Docker Configuration
|
|
# run: |
|
|
# cat /etc/docker/daemon.json
|
|
# docker info | grep -i "Registry Mirrors"
|
|
|
|
# Set up Docker Buildx
|
|
- name: Set up Docker Buildx
|
|
uses: http://fly6516.synology.me:4000/docker/setup-buildx-action@v2
|
|
|
|
# Log in to Gitea Docker Registry
|
|
- name: Log in to Gitea Docker Registry
|
|
uses: http://fly6516.synology.me:4000/docker/login-action@v2
|
|
with:
|
|
registry: https://fly6516.synology.me:8080
|
|
username: ${{ secrets.DOCKER_SYN_USER }}
|
|
password: ${{ secrets.DOCKER_SYN_PWD }}
|
|
|
|
- name: Set Docker Timeout
|
|
run: |
|
|
echo "DOCKER_CLIENT_TIMEOUT=300" >> $GITHUB_ENV
|
|
echo "DOCKER_BUILD_TIMEOUT=300" >> $GITHUB_ENV
|
|
|
|
# Build and push the Docker image
|
|
- name: Build and Push Docker Image
|
|
uses: http://fly6516.synology.me:4000/docker/build-push-action@v4
|
|
with:
|
|
push: true
|
|
tags: fly6516.synology.me:8080/multilang:latest
|
|
context: .
|
|
|
|
# Optional: Verify the pushed image
|
|
- name: Verify Docker Image
|
|
run: |
|
|
docker pull fly6516.synology.me:8080/multilang:latest
|
|
docker run --rm fly6516.synology.me:8080/multilang:latest bash -c "echo 'Image verified'"
|