diff --git a/.forgejo/workflows/build-and-deploy.yml b/.forgejo/workflows/build-and-deploy.yml index e366210..9ff5380 100644 --- a/.forgejo/workflows/build-and-deploy.yml +++ b/.forgejo/workflows/build-and-deploy.yml @@ -4,46 +4,46 @@ on: - 'main' jobs: - # build: - # name: Build Docker Image - # runs-on: ubuntu-latest - # container: catthehacker/ubuntu:act-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 + build: + name: Build Docker Image + runs-on: ubuntu-latest + container: catthehacker/ubuntu:act-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 - # - name: Create Kubeconfig for Buildx - # run: | - # mkdir -p $HOME/.kube - # echo "${{ secrets.KUBECONFIG_BUILDX }}" > $HOME/.kube/config + - name: Create Kubeconfig for Buildx + run: | + mkdir -p $HOME/.kube + echo "${{ secrets.KUBECONFIG_BUILDX }}" > $HOME/.kube/config - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 - # with: - # driver: kubernetes - # driver-opts: | - # namespace=codeberg + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: kubernetes + driver-opts: | + namespace=codeberg - # - name: Login to Docker Registry - # uses: docker/login-action@v3 - # with: - # username: janikvonrotz - # password: ${{ secrets.DOCKER_PAT }} + - name: Login to Docker Registry + uses: docker/login-action@v3 + with: + username: janikvonrotz + password: ${{ secrets.DOCKER_PAT }} - # - name: Build and push Docker image - # uses: docker/build-push-action@v5 - # with: - # context: . - # file: image/Dockerfile - # platforms: linux/amd64 - # tags: 'janikvonrotz/taskfile.build:latest' - # push: true + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: image/Dockerfile + platforms: linux/amd64 + tags: 'janikvonrotz/taskfile.build:latest' + push: true deploy: name: Deploy to Kubernetes runs-on: ubuntu-latest container: catthehacker/ubuntu:act-latest - # needs: build + needs: build steps: - name: Checkout code diff --git a/image/README.md b/image/README.md index eb0b5fa..94cf0ed 100644 --- a/image/README.md +++ b/image/README.md @@ -26,11 +26,15 @@ Run the tasfile.buld image: ```bash run() { echo "Open http://localhost:8080 in your browser" - docker run -p 8080:80 \ - -e GIT_URL="$GIT_URL" \ - -e TASK_COMMANDS="$TASK_COMMANDS" \ - -e CADDY_ROOT="$CADDY_ROOT" \ + docker rm -f taskfile-build + docker run -p 8080:80 -d \ + --name taskfile-build \ + -e GIT_URL="https://git.taskfile.build" \ + -e TASK_COMMANDS="install,build-11ty" \ + -e CADDY_ROOT="_site" \ + -v taskfile-build:/app \ janikvonrotz/taskfile.build:latest +} ``` The entrypoint script of the container will clone the project from git url. If the project is already cloned it will pull the origin. Afterwards it runs each command in the root of the cloned repository with the task file `./task `. Finally the Caddy webserver is started that serves static content from the root path. diff --git a/task b/task index 6860972..9f95f7c 100755 --- a/task +++ b/task @@ -128,10 +128,13 @@ export DOCKERFILE run() { echo "Open http://localhost:8080 in your browser" - docker run -p 8080:80 \ + docker rm -f taskfile-build + docker run -p 8080:80 -d \ + --name taskfile-build \ -e GIT_URL="https://git.taskfile.build" \ -e TASK_COMMANDS="install,build-11ty" \ -e CADDY_ROOT="_site" \ + -v taskfile-build:/app \ janikvonrotz/taskfile.build:latest }