commit 8d5c74f157ee661d401a0ba5f018861525054ff6 Author: Games <> Date: Thu Oct 29 17:13:20 2026 +0100 Initial commit diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml new file mode 100644 index 0000000..69bed00 --- /dev/null +++ b/.gitea/workflows/docker-build.yml @@ -0,0 +1,64 @@ +name: build container +on: + push: + paths: + - 'Dockerfile' + +env: + GIT_HOST: ${{ vars.AOIT_GIT_URL }} + GIT_REPO_NAME: ${{ gitea.event.repository.name }} + CONTAINER_TAG: ${{ gitea.repository }} + CONTAINER_NAME: deploy_test-${{ gitea.run_id }} + CONTAINER_VERSION: latest + +jobs: + build: + runs-on: test + steps: + - name: clone repo + working-directory: ${{ gitea.workspace }} + run: | + echo 'echo $TOKEN' > $GIT_ASKPASS + chmod +x $GIT_ASKPASS + git clone https://$GIT_HOST/$GIT_REPO +# cd $GIT_REPO_NAME +# git submodule update --init + env: + TOKEN: ${{ secrets.TOKEN_SVC_CI }} + GIT_ASKPASS: ${{ runner.temp }}/tmp.sh + GIT_REPO: ${{ gitea.repository }} + + - name: docker build + working-directory: ./${{ gitea.event.repository.name }} + run: docker build -t $GIT_HOST/$CONTAINER_TAG:$CONTAINER_VERSION . + + - name: test docker container comes up + run: docker run --rm -d --name $CONTAINER_NAME $GIT_HOST/$CONTAINER_TAG:$CONTAINER_VERSION + + - name: cleanup container + if: always() + run: docker kill $CONTAINER_NAME + + - name: upload container + run: | + docker login $GIT_HOST -u $REGISTRY_USER -p $REGISTRY_PASS + docker push $GIT_HOST/$CONTAINER_TAG:$CONTAINER_VERSION + docker logout + env: + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_PASS: ${{ secrets.TOKEN_SVC_DOCKER }} + + - name: docker cleanup image and build cache + run: | + docker image rm $GIT_HOST/$CONTAINER_TAG:$CONTAINER_VERSION + docker builder prune -af + + - name: inform if fail + if: ${{ failure() }} + run: curl -u $NTFY_USER:$NTFY_PASS -H tags:warning -d "$NTFY_DATA" $NTFY_HOST/$NTFY_CHANNEL + env: + NTFY_HOST: ${{ vars.NTFY_HOST }} + NTFY_USER: ${{ vars.NTFY_USER }} + NTFY_PASS: ${{ secrets.NTFY_PASS }} + NTFY_DATA: deployment of ${{ gitea.repository }} fails + NTFY_CHANNEL: ${{ vars.NTFY_CHANNEL }} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..847401a --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025 templatecity + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..441e5fb --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# docker-builder + +## setup +Set Repo / Org vars: +- AOIT_GIT_URL +- NTFY_HOST +- NTFY_USER +- NTFY_CHANNEL + +Set Repo / Org Secrets +- TOKEN_SVC_CI (for download repo) +- TOKEN_SVC_DOCKER (for upload container) +- REGISTRY_USER (for upload container) +- NTFY_PASS \ No newline at end of file