Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoupling the image build process from the flow #221

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/main.yml → .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:

jobs:
build:
env:
context: beyond
image_name: beyond
runs-on: ubuntu-18.04
steps:
- name: Checkout source tree
Expand Down Expand Up @@ -35,8 +38,27 @@ jobs:
tar -xzf geckodriver-v0.26.0-linux64.tar.gz -C geckodriver
pip install -r tests/requirements-test.txt

- name: Build the docker-compose stack
run: docker-compose up -d
# - name: Build the docker-compose stack
# run: docker-compose up -d

- name: Check and verify version.json
id: check_version
run: |
echo -n ::set-output name=IMAGE_TAGS::
echo $(jq -r '.version' version.json)

- name: Build Beyond image
uses: docker/build-push-action@v1
with:
path: .
push: false
repository: ${{ env.image_name }}
tags: ${{ steps.check_version.outputs.IMAGE_TAGS }}

- name: Run Beyond image
run: |
echo "Running: docker run -d -p 5000:5000 --name ${image_name} ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }}"
docker run -d -p 5000:5000 --name ${image_name} ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }}

- name: Execute tests
run: |
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish

on:
push:
# pull_request:
# pull_request_target:
# types: [review_requested, edited]
branches:
- master
tags:
- '*'
paths:
- version.json
jobs:
build:
env:
context: beyond
image_name: beyond
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- name: Get image tags
id: image_tags
run: |
echo -n ::set-output name=IMAGE_TAGS::
VERSION=$(jq -r '.version' version.json)
TAGS=('latest')
if [ "${VERSION}" ] && [ "${VERSION}" != "latest" ]; then
TAGS+=("${VERSION}")
fi
if [[ "${GITHUB_REF}" =~ refs/tags/(.*) ]]; then
TAGS+=("git-${BASH_REMATCH[1]}")
fi
( IFS=$','; echo "${TAGS[*]}" )

- name: Build and publish image to Quay
uses: docker/build-push-action@v1
with:
registry: quay.io
username: "redhat-beyond+robot"
password: ${{ secrets.REGISTRY_PASSWORD }}
repository: redhat-beyond/beyond
tags: latest
# path: .
# registry: ${{ secrets.REGISTRY_URI }}
# repository: ${{ secrets.REGISTRY_REPOSITORY }}
# username: ${{ secrets.REGISTRY_USERNAME }}
# password: ${{ secrets.REGISTRY_PASSWORD }}
# tags: "${{ steps.image_tags.outputs.IMAGE_TAGS }}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ COPY . .
RUN pip3 install -r requirements.txt
EXPOSE 5000

ENTRYPOINT python3 app.py runserver > web-application.log
ENTRYPOINT python3 app.py runserver > web-application.log
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.9'
services:
beyond:
build: .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the build key removed?

Copy link
Collaborator Author

@IlanZuckerman IlanZuckerman Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the image build stage is now removed from this flow.
The image is ready and being hosted on quayei already. We just need to pull it and thats it.

From $ vagrant up stage --provider=aws :
.
.
.
==> stage: Pulling beyond (quay.io/redhat-beyond/beyond:)...
stage: latest: Pulling from redhat-beyond/beyond

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is wrong with this concept. An automatic build should happen when a code change lands in master.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, there should be a different flow for building and pushing the image. lets discuss this in my reply on your comment from above (to avoid duplicated messages)

image: quay.io/redhat-beyond/beyond
container_name: beyond
ports:
- "5000:5000"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests
from pystemd.systemd1 import Unit

CONTAINER_NAMES = ['beyond', 'postgres']
CONTAINER_NAMES = ['beyond']


def test_webserver_response_code():
Expand Down
1 change: 1 addition & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"v1.0.1"}