mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-24 00:20:24 +00:00
test docker build
This commit is contained in:
parent
96a1914be5
commit
d939d4ed4f
8 changed files with 142 additions and 242 deletions
81
.github/workflows/build_apphub.yml
vendored
81
.github/workflows/build_apphub.yml
vendored
|
@ -1,81 +0,0 @@
|
|||
name: Push apphub image To DockerHub, and upload Websoft9 API to https://support.websoft9.com/apidocs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "docker/apphub/Dockerfile"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Docker image
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TAGS: latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
name: Check out code
|
||||
|
||||
- name: Get version
|
||||
run: |
|
||||
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/apphub/Dockerfile)
|
||||
echo $version
|
||||
real_version=${version%%-*}
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
if [ "$version" != "$real_version" ]; then
|
||||
version_list=$version
|
||||
else
|
||||
IFS='.' read -ra VERSION_PARTS <<< "$real_version"
|
||||
version_list="latest"
|
||||
version_accumulator=""
|
||||
for i in "${VERSION_PARTS[@]}"; do
|
||||
if [ -z "$version_accumulator" ]; then
|
||||
version_accumulator=$i
|
||||
else
|
||||
version_accumulator=$version_accumulator.$i
|
||||
fi
|
||||
version_list=$version_accumulator,$version_list
|
||||
done
|
||||
fi
|
||||
echo "VERSION_LIST=$version_list" >> $GITHUB_ENV
|
||||
|
||||
- uses: mr-smithers-excellent/docker-build-push@v5
|
||||
name: Build & push Docker image
|
||||
with:
|
||||
image: websoft9dev/apphub
|
||||
tags: ${{ env.VERSION_LIST }}
|
||||
addLatest: True
|
||||
registry: docker.io
|
||||
dockerfile: docker/apphub/Dockerfile
|
||||
directory: docker/apphub
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Download redoc.standalone.js
|
||||
run: wget -O apphub/apidocs/redoc.standalone.js https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js
|
||||
|
||||
- name: Run Docker container and get openapi.json
|
||||
run: |
|
||||
docker run -d --name apphub -p 8080:8080 websoft9dev/apphub:${{ env.VERSION }}
|
||||
sleep 5
|
||||
max_attempts=10
|
||||
url="http://localhost:8080/openapi.json"
|
||||
for attempt in $(seq 1 $max_attempts); do
|
||||
echo "Attempt #$attempt to download $url..."
|
||||
if wget -O apphub/apidocs/openapi.json "$url"; then
|
||||
echo "Successfully downloaded $url"
|
||||
break
|
||||
else
|
||||
echo "Failed to download $url. Waiting for 5 seconds before retry..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Upload Websoft9 API to Azure
|
||||
uses: bacongobbler/azure-blob-storage-upload@main
|
||||
with:
|
||||
source_dir: apphub/apidocs
|
||||
container_name: $web
|
||||
connection_string: ${{ secrets.Azure_blob }}
|
||||
extra_args: '--destination-path ./apidocs'
|
||||
overwrite: true
|
52
.github/workflows/build_deployment.yml
vendored
52
.github/workflows/build_deployment.yml
vendored
|
@ -1,52 +0,0 @@
|
|||
name: portainer Build And Push To DockerHub
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "docker/deployment/Dockerfile"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Docker image
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TAGS: latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
name: Check out code
|
||||
|
||||
- name: Get version
|
||||
run: |
|
||||
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/deployment/Dockerfile)
|
||||
echo $version
|
||||
real_version=${version%%-*}
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
if [ "$version" != "$real_version" ]; then
|
||||
version_list=$version
|
||||
else
|
||||
IFS='.' read -ra VERSION_PARTS <<< "$real_version"
|
||||
version_list="latest"
|
||||
version_accumulator=""
|
||||
for i in "${VERSION_PARTS[@]}"; do
|
||||
if [ -z "$version_accumulator" ]; then
|
||||
version_accumulator=$i
|
||||
else
|
||||
version_accumulator=$version_accumulator.$i
|
||||
fi
|
||||
version_list=$version_accumulator,$version_list
|
||||
done
|
||||
fi
|
||||
echo "VERSION_LIST=$version_list" >> $GITHUB_ENV
|
||||
|
||||
- uses: mr-smithers-excellent/docker-build-push@v5
|
||||
name: Build & push Docker image
|
||||
with:
|
||||
image: websoft9dev/deployment
|
||||
tags: ${{ env.VERSION_LIST }}
|
||||
addLatest: True
|
||||
registry: docker.io
|
||||
dockerfile: docker/deployment/Dockerfile
|
||||
directory: docker/deployment
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
52
.github/workflows/build_git.yml
vendored
52
.github/workflows/build_git.yml
vendored
|
@ -1,52 +0,0 @@
|
|||
name: gitea Build And Push To DockerHub
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "docker/git/Dockerfile"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Docker image
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TAGS: latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
name: Check out code
|
||||
|
||||
- name: Get version
|
||||
run: |
|
||||
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/git/Dockerfile)
|
||||
echo $version
|
||||
real_version=${version%%-*}
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
if [ "$version" != "$real_version" ]; then
|
||||
version_list=$version
|
||||
else
|
||||
IFS='.' read -ra VERSION_PARTS <<< "$real_version"
|
||||
version_list="latest"
|
||||
version_accumulator=""
|
||||
for i in "${VERSION_PARTS[@]}"; do
|
||||
if [ -z "$version_accumulator" ]; then
|
||||
version_accumulator=$i
|
||||
else
|
||||
version_accumulator=$version_accumulator.$i
|
||||
fi
|
||||
version_list=$version_accumulator,$version_list
|
||||
done
|
||||
fi
|
||||
echo "VERSION_LIST=$version_list" >> $GITHUB_ENV
|
||||
|
||||
- uses: mr-smithers-excellent/docker-build-push@v5
|
||||
name: Build & push Docker image
|
||||
with:
|
||||
image: websoft9dev/git
|
||||
tags: ${{ env.VERSION_LIST }}
|
||||
addLatest: True
|
||||
registry: docker.io
|
||||
dockerfile: docker/git/Dockerfile
|
||||
directory: docker/git
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
52
.github/workflows/build_proxy.yml
vendored
52
.github/workflows/build_proxy.yml
vendored
|
@ -1,52 +0,0 @@
|
|||
name: NginxProxyManage Build And Push To DockerHub
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "docker/proxy/Dockerfile"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Docker image
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TAGS: latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
name: Check out code
|
||||
|
||||
- name: Get version
|
||||
run: |
|
||||
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/proxy/Dockerfile)
|
||||
echo $version
|
||||
real_version=${version%%-*}
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
if [ "$version" != "$real_version" ]; then
|
||||
version_list=$version
|
||||
else
|
||||
IFS='.' read -ra VERSION_PARTS <<< "$real_version"
|
||||
version_list="latest"
|
||||
version_accumulator=""
|
||||
for i in "${VERSION_PARTS[@]}"; do
|
||||
if [ -z "$version_accumulator" ]; then
|
||||
version_accumulator=$i
|
||||
else
|
||||
version_accumulator=$version_accumulator.$i
|
||||
fi
|
||||
version_list=$version_accumulator,$version_list
|
||||
done
|
||||
fi
|
||||
echo "VERSION_LIST=$version_list" >> $GITHUB_ENV
|
||||
|
||||
- uses: mr-smithers-excellent/docker-build-push@v5
|
||||
name: Build & push Docker image
|
||||
with:
|
||||
image: websoft9dev/proxy
|
||||
tags: ${{ env.VERSION_LIST }}
|
||||
addLatest: True
|
||||
registry: docker.io
|
||||
dockerfile: docker/proxy/Dockerfile
|
||||
directory: docker/proxy
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
92
.github/workflows/docker.yml
vendored
Normal file
92
.github/workflows/docker.yml
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
# This action is used for building websoft9 docker images to DockerHub at one time
|
||||
# It need LABEL version="" at your dockerfile. And it can divide version. e.g version v3.4.0.3 will divide to latest,v3,v3.4,v3.4.0,v3.4.0.3
|
||||
# When version include "-", it not divide version and build ony one test image
|
||||
# It have enable multiPlatform, you add more platform at platform: linux/amd64...
|
||||
# If you add more paths for trigger, please update app_list= at set-matrix for it also
|
||||
|
||||
name: Build image to DockerHub
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "docker/*/Dockerfile"
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- id: set-matrix
|
||||
run: |
|
||||
git diff --name-only HEAD^ HEAD
|
||||
changed_files=$(git diff --name-only HEAD^ HEAD)
|
||||
app_list=$(echo "$changed_files" | grep -E 'docker/.*/(Dockerfile)' | awk -F'/' '{print $2}' | sort | uniq)
|
||||
app_list_json=$(echo $app_list | jq -R -s -c 'split(" ")')
|
||||
echo "::set-output name=matrix::{\"app\": $app_list_json}"
|
||||
|
||||
build:
|
||||
needs: setup
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Prepare tags and files for Docker build
|
||||
run: |
|
||||
APP=${{ matrix.app }}
|
||||
TAG=$(grep 'LABEL version' "docker/$APP/Dockerfile" | cut -d'"' -f2 | xargs)
|
||||
echo $APP version is $TAG
|
||||
if [[ "$TAG" == *"-"* ]]; then
|
||||
TAGS="$TAG"
|
||||
else
|
||||
IFS='.' read -ra PARTS <<< "$TAG"
|
||||
TAGS="latest"
|
||||
TAG_PART=""
|
||||
for i in "${!PARTS[@]}"; do
|
||||
if [ "$i" -eq 0 ]; then
|
||||
TAG_PART="${PARTS[$i]}"
|
||||
else
|
||||
TAG_PART="${TAG_PART}.${PARTS[$i]}"
|
||||
fi
|
||||
TAGS="${TAGS},${TAG_PART}"
|
||||
done
|
||||
fi
|
||||
echo "Building and pushing Docker image for $APP with tags: $TAGS"
|
||||
echo "TAGS=$TAGS" >> $GITHUB_ENV
|
||||
echo "APP=$APP" >> $GITHUB_ENV
|
||||
echo "DOCKERFILE=docker/$APP/Dockerfile" >> $GITHUB_ENV
|
||||
echo "DIRECTORY=docker/$APP" >> $GITHUB_ENV
|
||||
echo "README=docker/$APP/README.md" >> $GITHUB_ENV
|
||||
|
||||
- name: Build & push Docker image
|
||||
uses: mr-smithers-excellent/docker-build-push@v6
|
||||
with:
|
||||
image: websoft9dev/${{env.APP}}
|
||||
tags: ${{env.TAGS}}
|
||||
registry: docker.io
|
||||
directory: ${{env.DIRECTORY}}
|
||||
dockerfile: ${{env.DOCKERFILE}}
|
||||
multiPlatform: true
|
||||
platform: linux/amd64
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: websoft9dev/${{env.APP}}
|
||||
readme-filepath: ${{env.README}}
|
||||
if: needs.setup.outputs.matrix != ''
|
|
@ -1,4 +1,4 @@
|
|||
name: upload_artifact(decide by version)
|
||||
name: Release to Github and Artifact
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
@ -13,7 +13,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
name: Check out code
|
||||
|
||||
- name: Version convert
|
||||
|
@ -80,4 +80,49 @@ jobs:
|
|||
title: Release-${{ steps.convert_version.outputs.VERSION }}
|
||||
body: ${{ steps.update_data.outputs.CHANGELOG }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
prerelease: false
|
||||
|
||||
|
||||
apidocs:
|
||||
needs: upload_artifact
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
name: Check out code
|
||||
|
||||
- name: Get version
|
||||
run: |
|
||||
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/apphub/Dockerfile)
|
||||
echo $version
|
||||
real_version=${version%%-*}
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
|
||||
- name: Download redoc.standalone.js
|
||||
run: wget -O apphub/apidocs/redoc.standalone.js https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js
|
||||
|
||||
- name: Run Docker container and get openapi.json
|
||||
run: |
|
||||
docker run -d --name apphub -p 8080:8080 websoft9dev/apphub:${{ env.VERSION }}
|
||||
sleep 5
|
||||
max_attempts=10
|
||||
url="http://localhost:8080/openapi.json"
|
||||
for attempt in $(seq 1 $max_attempts); do
|
||||
echo "Attempt #$attempt to download $url..."
|
||||
if wget -O apphub/apidocs/openapi.json "$url"; then
|
||||
echo "Successfully downloaded $url"
|
||||
break
|
||||
else
|
||||
echo "Failed to download $url. Waiting for 5 seconds before retry..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Upload Websoft9 API to Azure
|
||||
uses: bacongobbler/azure-blob-storage-upload@main
|
||||
with:
|
||||
source_dir: apphub/apidocs
|
||||
container_name: $web
|
||||
connection_string: ${{ secrets.Azure_blob }}
|
||||
extra_args: '--destination-path ./apidocs'
|
||||
overwrite: true
|
|
@ -1,4 +1,4 @@
|
|||
# modify time: 202312071717, you can modify here to trigger Docker Build action
|
||||
# modify time: 2023120081104, you can modify here to trigger Docker Build action
|
||||
|
||||
FROM python:3.10-slim-bullseye
|
||||
LABEL maintainer="Websoft9<help@websoft9.com>"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# modify time: 202312060952, you can modify here to trigger Docker Build action
|
||||
# modify time: 202312081103, you can modify here to trigger Docker Build action
|
||||
# Dockerfile refer to: https://github.com/go-gitea/gitea/blob/main/Dockerfile
|
||||
FROM gitea/gitea:1.20.4
|
||||
|
||||
|
|
Loading…
Reference in a new issue