From 23e18aa8e58e2699c88d6b589995db5bf8ceba5a Mon Sep 17 00:00:00 2001 From: Fabricio C Zuardi Date: Wed, 6 Dec 2023 10:11:55 -0300 Subject: [PATCH] feat(github-actions): build webapp image --- .github/workflows/docker-image.yml | 59 ++++++++++++++++++++++++++++-- Dockerfile | 1 + justfile | 8 ++-- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 20876f6..7830883 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -4,17 +4,18 @@ on: push: branches: - main + - bucket-tester-app-image env: REGISTRY: ghcr.io DOCKER_USERNAME: fczuardi IMAGE_NAME: ${{ github.repository }} jobs: - build: + build-main: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Login to Docker Hub uses: docker/login-action@v3 @@ -25,14 +26,64 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} - - name: Build and push Docker image + - name: Build and push (main) Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + build-webapp: + runs-on: ubuntu-latest + container: ghcr.io/marmotitude/object-storage-tests:bucket-tester-app-image + # TODO: try to use the project's OCI that have gotpl and just installed already + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Pre-build webapp + run: | + pwd + ls . + ls ../ + just + cat example.config.yaml + gotpl -f example.config.yaml src/templates/nginx.conf --output . + cat nginx.conf + + # cd \app + # cp example.config.yaml config.yaml + # just _pre-build-webapp + # install just + # - run: wget -qO - 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null + # - run: echo "deb [arch=all,$(dpkg --print-architecture) signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $(lsb_release -cs)" | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list + # - run: sudo apt update + # - run: sudo apt install just + # # install gotpl + # - run: wget https://github.com/belitre/gotpl/releases/download/v0.7/gotpl-v0.7-linux-amd64.zip && unzip gotpl-v0.7-linux-amd64.zip + # - run: sudo cp linux-amd64/gotpl /usr/bin + # write nginx.conf + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push (webapp) Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + file: webapp.Dockerfile + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:webapp diff --git a/Dockerfile b/Dockerfile index 903f805..d8563c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,7 @@ RUN pip install --no-cache-dir python-swiftclient RUN pip install --no-cache-dir python-keystoneclient WORKDIR /app +COPY example.config.yaml /app/example.config.yaml COPY src /app/src COPY vendor /app/vendor COPY justfile /app/justfile diff --git a/justfile b/justfile index f456077..1fcdd1c 100644 --- a/justfile +++ b/justfile @@ -125,12 +125,14 @@ build builder=oci_manager: build-dev builder=oci_manager: {{builder}} build --rm -t {{devshell_image}} -f ./devshell.Dockerfile . -# Build webapp image. -build-webapp builder=oci_manager: +_pre-build-webapp: # write ./nginx.conf to be copied by Dockerfile gotpl -f config.yaml src/templates/nginx.conf --output . - {{builder}} build --rm -t {{webapp_image}} -f ./webapp.Dockerfile . +# Build webapp image. +build-webapp builder=oci_manager: + @just _pre-build-webapp + {{builder}} build --rm -t {{webapp_image}} -f ./webapp.Dockerfile . # Private recipes #----------------