Skip to content

Commit

Permalink
Merge pull request #42 from cam-inc/feat/build-and-push-container-ima…
Browse files Browse the repository at this point in the history
…ge-to-ghcr

feat: build and push container image to GHCR.
  • Loading branch information
mugioka committed Apr 2, 2024
2 parents b76d386 + b917fd5 commit 7e31869
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 21 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/build.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
name: Build
name: CI
on:
# NOTE: To comment SonarCloud coverage to GitHub Pull Request, we need to run the CI on pull requests.
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- '**'
pull_request:
types: [opened, reopened]

- develop
- main
jobs:
sonarcloud:
name: SonarCloud
test:
name: Test and upload coverage to SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5.0.0
with:
go-version: 1.17
go-version: 1.22.1

- name: Test
- name: Test with coverage
run: go test --tags=test -coverprofile=cover.out $(go list ./... | grep -v mxtransporter/cmd)

- name: SonarCloud Scan
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'
jobs:
publish-container-image:
name: Publish Container Image to GitHub Container Registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1

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

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

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

- name: Get metadata
id: get-metadata
uses: docker/metadata-action@v5.5.1
with:
images: ghcr.io/${{ github.repository }}
flavor: |
latest=true
tags: |
type=ref event=push tag
- name: Build and push
uses: docker/build-push-action@v5.3.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.get-metadata.outputs.tags }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
## Build
##
FROM golang:latest as build
FROM golang:1.22.1-bookworm as build

LABEL org.opencontainers.image.source="https://github.com/cam-inc/MxTransporter"

Expand All @@ -24,7 +24,7 @@ RUN go install ./cmd/health.go
##
## Deploy
##
FROM alpine:latest
FROM alpine:3.19.1

WORKDIR /go/src

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:latest
FROM golang:1.22.1-bookworm

WORKDIR /go/src

Expand Down
4 changes: 1 addition & 3 deletions docker-compose.mongo-replica.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: '3.8'

services:

mongodb-primary:
image: mongo
command:
Expand All @@ -22,7 +21,7 @@ services:

mongodb-secondary:
image: mongo
command:
command:
- --replSet
- rs0
volumes:
Expand All @@ -39,4 +38,3 @@ services:
expose:
- 27017
restart: always

5 changes: 2 additions & 3 deletions docker-compose.mxt-local.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: '3.8'

services:

mxt:
build:
context: '.'
Expand All @@ -21,12 +20,12 @@ services:
extends:
file: docker-compose.mongo-replica.yml
service: mongodb-primary

mongodb-secondary:
extends:
file: docker-compose.mongo-replica.yml
service: mongodb-secondary

mongodb-arbiter:
extends:
file: docker-compose.mongo-replica.yml
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cam-inc/mxtransporter

go 1.17
go 1.22

require (
cloud.google.com/go/bigquery v1.18.0
Expand Down

0 comments on commit 7e31869

Please sign in to comment.