Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Publish Docker Images to GH Packages on merge with main #86

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build Docker Images & Push to Registry

Copy link

Choose a reason for hiding this comment

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

I assume this is a cloudbuild yaml? I would leave cloudbuild in the name somewhere if so

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Frontend Docker image
working-directory: ./app
run: |
docker login docker.pkg.github.com -u ${{ secrets.USERNAME }} --password ${{ secrets.GITHUB_TOKEN }}
docker build . --file Dockerfile --tag frontend
docker tag frontend docker.pkg.github.com/googleinterns/major-tom/frontend
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct me if I am wrong but, are these URL's correct? I thought that for pushing to Google's Container Registry you had to prefix your images with the following format:

gcr.io/$PROJECT_ID/$IMAGE_NAME
i.e. gcr.io/major-tom-123/frontend

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this pr is about publishing our latest image to the repo not to gcp's container registry

docker push docker.pkg.github.com/googleinterns/major-tom/frontend
- name: Build Backend Docker image
working-directory: ./server
run: |
docker build . --file Dockerfile --tag backend
docker tag backend docker.pkg.github.com/googleinterns/major-tom/backend
Copy link

Choose a reason for hiding this comment

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

Isn't this tag lost if you don't push it with this tag too?

docker push docker.pkg.github.com/googleinterns/major-tom/backend
- name: Build Keywords Docker image
working-directory: ./services/keywords
run: |
docker build . --file Dockerfile --tag keywords
docker tag keywords docker.pkg.github.com/googleinterns/major-tom/keywords
docker push docker.pkg.github.com/googleinterns/major-tom/keywords
- name: Build Search Docker image
working-directory: ./services/search
run: |
docker build . --file Dockerfile --tag search
docker tag search docker.pkg.github.com/googleinterns/major-tom/search
docker push docker.pkg.github.com/googleinterns/major-tom/search
- name: Build Parser Docker image
working-directory: ./services/parser-database
run: |
docker build . --file Dockerfile --tag parser-database
Copy link
Contributor

Choose a reason for hiding this comment

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

I am pretty confident you can omit the --file flag as Docker looks for that file by default.

docker tag parser-database docker.pkg.github.com/googleinterns/major-tom/parser-database
docker push docker.pkg.github.com/googleinterns/major-tom/parser-database
Comment on lines +12 to +42
Copy link
Contributor

Choose a reason for hiding this comment

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

the docker login could be moved to a separate step and then the build step could be parameterized as a matrix job