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

Feature 39 setup build and publish image #48

Merged
merged 49 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7af15fb
feat: Setup docker build and publish on ghcr
kouamschekina Mar 5, 2024
a8b3189
feat: Setup docker build and publish on ghcr
kouamschekina Mar 5, 2024
6ef381d
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
c0d78e6
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
d8fed14
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
7ff8077
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
c89a25e
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
9c4769d
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
405196f
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
1b0ab88
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
04b1cb1
fix: Updated workflow files to handle the Change String Case
kouamschekina Mar 5, 2024
2c91199
feat: Created a workflow file that builds and pushes docker images fo…
kouamschekina Mar 5, 2024
d15c9e4
Merge branch 'main' into feature-39-setup-build-and-publish-image
stephane-segning Mar 5, 2024
496b12a
fix: Updated the Change String Case in th workflow files
kouamschekina Mar 5, 2024
8777052
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 5, 2024
37ef23e
fix: Updated the Change String Case in th workflow files
kouamschekina Mar 5, 2024
eb42070
fix: Updated the Change String Case in th workflow files
kouamschekina Mar 5, 2024
52df277
feat: Documented the process used to build and upload docker images t…
kouamschekina Mar 6, 2024
25ebe82
feat: Documented the process used to build and upload docker images t…
kouamschekina Mar 6, 2024
4663b73
fix: changed string conversion using change string case
kouamschekina Mar 6, 2024
f8169de
fix: changed string conversion using change string case
kouamschekina Mar 6, 2024
2a2f93c
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 6, 2024
bf0fabf
fix: changed string conversion using change string case
kouamschekina Mar 6, 2024
29097fa
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 6, 2024
5a9a741
fix: handled the permissions
kouamschekina Mar 6, 2024
c46762d
fix: handled the permissions on the frontend and translator
kouamschekina Mar 6, 2024
e90463d
fix: handled the permissions on the translator
kouamschekina Mar 6, 2024
00c9d8b
fix: handled the permissions on the translator
kouamschekina Mar 6, 2024
0f0950a
fix: handled image url for frontend
kouamschekina Mar 6, 2024
a9811aa
fix: handled image url for frontend
kouamschekina Mar 6, 2024
0099946
fix: update env with image names
kouamschekina Mar 6, 2024
b2f4043
fix: handled image url for frontend
kouamschekina Mar 6, 2024
4a2c27a
fix: modified version of the setup-buildx-action
kouamschekina Mar 6, 2024
ee68b12
Merge branch 'ADORSYS-GIS:main' into feature-39-setup-build-and-publi…
kouamschekina Mar 6, 2024
c24ba9f
feat: Documented the process used to build and upload docker images t…
kouamschekina Mar 6, 2024
567e1ea
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 6, 2024
4367cff
fix: Updated tags in the frontend
kouamschekina Mar 6, 2024
538e4a5
feat: update rust.yml
stephane-segning Mar 7, 2024
6c3fca7
feat: update rust.yml to fix CI/CD
stephane-segning Mar 7, 2024
3d9f561
fix: Updated the building and uploading docker images' docs
kouamschekina Mar 7, 2024
014f999
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 7, 2024
e36e5d0
fix: Updated tags in the frontend and backend files
kouamschekina Mar 7, 2024
9616c37
Merge branch 'main' into feature-39-setup-build-and-publish-image
kouamschekina Mar 7, 2024
e6ccbfb
fix: ci/cd update and rename rust.yml to build-translator.yml
stephane-segning Mar 7, 2024
8981c33
fix: ci/cd - update and rename maven.yml to build-service.yml
stephane-segning Mar 7, 2024
b254b8c
fix: typo error in job's name
stephane-segning Mar 7, 2024
f57cbc1
fix: renamed the node.yml to build-frontend.yaml and modified the bui…
kouamschekina Mar 7, 2024
1deff03
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 7, 2024
396c392
fix: delete .github/workflows/node.yml
stephane-segning Mar 7, 2024
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
71 changes: 71 additions & 0 deletions .github/workflows/build-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build NodeJS

on:
push:
branches:
- '**'
tags-ignore:
- 'v*'
pull_request:
branches:
- '**'

env:
REGISTRY: ghcr.io
# IMAGE_URL: "ghcr.io/my-org/my-image:1.0.0"
IMAGE_NAME: ${{ github.repository }}-frontend


jobs:
build:

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Npm install
run: cd power-pay-frontend && npm ci

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to the Docker registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Frontend
run: cd power-pay-frontend && npm run build

- id: string
uses: AsZc/change-string-case-action@v6
with:
string: ${{ env.IMAGE_NAME }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.string.outputs.lowercase }}

- name: Build and push
uses: docker/build-push-action@v4
if: github.event_name != 'pull_request'
with:
context: ./power-pay-frontend
file: ./power-pay-frontend/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
70 changes: 70 additions & 0 deletions .github/workflows/build-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build Backend

on:
push:
branches:
- '**'
tags-ignore:
- 'v*'
pull_request:
branches:
- '**'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-backend


jobs:
build:

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Backend
run: cd power-pay-backend && mvn package

- id: string
uses: ASzc/change-string-case-action@v6
with:
string: ${{ env.IMAGE_NAME}}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.string.outputs.lowercase }}

- name: Build and push image
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request'
with:
context: ./power-pay-backend
file: ./power-pay-backend/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Translator v2
name: Build Translator

on:
push:
Expand All @@ -15,7 +15,6 @@ env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-translator


jobs:
build:

Expand Down Expand Up @@ -58,6 +57,7 @@ jobs:

- name: Build and push Docker image
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request'
with:
context: ./power-pay-translator
push: true
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/maven.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/node.yml

This file was deleted.

37 changes: 37 additions & 0 deletions docs/Setup-build-and-push-docker-images.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Building and Uploading Docker Images to ghcr.io using Github Action
This document outlines the steps to build a Docker image and upload it to ghcr.io using a Github Action. The process involves building the frontend, backend and using a translator service to communicate with them.

## About Github Actions
Github Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and publish docker images on the ghcr.io, test every pull request to your directory. For a deeper understanding you can see [Learn Github Actions](https://docs.github.com/en/actions/learn-github-actions)

## Prerequisites
- A Github repository for each sub-project with a Dockerfile.
- A personal access token (PAT) with write:packages scope. You can create a PAT by following these steps: [Github Docs ](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)

### Step 1.
- Create new files named:
.github/workflows/maven.yml,
.github/workflows/node.yml, and
.github/workflows/rust.yml
in the main project directory for the backend, frontend and translator respectively.

### Step 2.
- In the above created files, define the Github Action workflow for each.

### Step 3.
- Save the various .yml files.

### Step 4.
- Commit and push the changes to your repository.

### Step 5.
- Github Action will automatically trigger the workflow defined in the above files whenever pushed to the mentioned branch.

### Step 6.
- The workflow will build the frontend, backend and translator Docker images using their respective Dockerfiles and push them to ghcr.io using the provided credentials.

### Step 7.
- You can access the Docker images on ghcr.io at ghcr.io/<owner>/<repository>/<image>:<tag>, where <owner> is your GitHub username or organization, <repository> is the name of your repository, <image> is the name of the Docker image(frontend, backend or translator) and <tag> is the SHA of the commit.

### Step 8.
- Make sure to update your deployment or other relevant scripts to use the newly built Docker images from ghcr.io.
Loading