Skip to content

Commit

Permalink
link ghcr package to repo
Browse files Browse the repository at this point in the history
link ghcr package to repo

link ghcr package to repo
  • Loading branch information
jacobnguyenn committed Aug 23, 2023
1 parent 2704ac7 commit e49f73b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ jobs:
SERVICE_NAME: ${{ inputs.SERVICE_NAME }}
IMAGE_TAG: ${{ inputs.IMAGE_TAG }}
steps:
- uses: actions/checkout@v2
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GH_PAT}}
- name: 'Build Backend Image'
run: |
docker build --build-arg VERSION=${{ env.IMAGE_TAG }} --build-arg GIT_COMMIT=${{ github.sha }} --build-arg GIT_TREE_STATE=clean -f backend.Dockerfile . --tag ghcr.io/${{github.actor}}/gorya-backend:${{ env.IMAGE_TAG }}
- uses: actions/checkout@v2
- name: "Checkout GitHub Action"
uses: actions/checkout@main
- name: "Login to GitHub Container Registry"
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GH_PAT}}
- name: "Build Backend Image"
run: |
docker build --build-arg VERSION=${{ env.IMAGE_TAG }} --build-arg GIT_COMMIT=${{ github.sha }} --build-arg GIT_TREE_STATE=clean --build-arg GH_ACTOR=${{github.actor}} --build-arg GH_REPO=${{ github.event.repository.name }} -f backend.Dockerfile . --tag ghcr.io/${{github.actor}}/gorya-backend:${{ env.IMAGE_TAG }}
docker push ghcr.io/${{github.actor}}/gorya-backend:${{ env.IMAGE_TAG }}
docker push ghcr.io/${{github.actor}}/gorya-backend:${{ env.IMAGE_TAG }}
ui_image_publish:
runs-on: "ubuntu-20.04"
if: ${{ inputs.SERVICE_NAME == 'gorya-ui' }}
Expand All @@ -42,15 +42,15 @@ jobs:
IMAGE_TAG: ${{ inputs.IMAGE_TAG }}
steps:
- uses: actions/checkout@v2
- name: 'Checkout GitHub Action'
- name: "Checkout GitHub Action"
uses: actions/checkout@main
- name: 'Login to GitHub Container Registry'
- name: "Login to GitHub Container Registry"
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GH_PAT}}
- name: 'Build UI Image'
- name: "Build UI Image"
run: |
docker build -f frontend.Dockerfile . --tag ghcr.io/${{github.actor}}/gorya-ui:${{ env.IMAGE_TAG }}
docker push ghcr.io/${{github.actor}}/gorya-ui:${{ env.IMAGE_TAG }}
docker build --build-arg GH_ACTOR=${{github.actor}} --build-arg GH_REPO=${{ github.event.repository.name }} -f frontend.Dockerfile . --tag ghcr.io/${{github.actor}}/gorya-ui:${{ env.IMAGE_TAG }}
docker push ghcr.io/${{github.actor}}/gorya-ui:${{ env.IMAGE_TAG }}
10 changes: 6 additions & 4 deletions backend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM cgr.dev/chainguard/go AS builder
ARG TARGETOS
ARG TARGETARCH

ARG GH_ACTOR=nduyphuong
ARG GH_REPO=gorya
LABEL org.opencontainers.image.source https://github.com/${GH_ACTOR}/${GH_REPO}
LABEL org.opencontainers.image.licenses MIT
ARG VERSION_PACKAGE=github.com/nduyphuong/gorya/internal/version

ARG VERSION
Expand All @@ -10,11 +13,10 @@ ARG GIT_TREE_STATE
COPY . /app

RUN cd /app && GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
-ldflags "-w -X ${VERSION_PACKAGE}.version=${VERSION} -X ${VERSION_PACKAGE}.buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -X ${VERSION_PACKAGE}.gitCommit=${GIT_COMMIT} -X ${VERSION_PACKAGE}.gitTreeState=${GIT_TREE_STATE}" \
-o gorya ./cmd \
-ldflags "-w -X ${VERSION_PACKAGE}.version=${VERSION} -X ${VERSION_PACKAGE}.buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -X ${VERSION_PACKAGE}.gitCommit=${GIT_COMMIT} -X ${VERSION_PACKAGE}.gitTreeState=${GIT_TREE_STATE}" \
-o gorya ./cmd \
&& ./gorya version

FROM cgr.dev/chainguard/glibc-dynamic
COPY --from=builder /app/gorya /usr/bin/
CMD ["/usr/bin/gorya", "api"]

4 changes: 4 additions & 0 deletions frontend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# pull official base image
FROM node:current-alpine3.18
ARG GH_ACTOR=nduyphuong
ARG GH_REPO=gorya
LABEL org.opencontainers.image.source https://github.com/${GH_ACTOR}/${GH_REPO}
LABEL org.opencontainers.image.licenses MIT

ENV NODE_OPTIONS=--openssl-legacy-provider
# set working directory
Expand Down

0 comments on commit e49f73b

Please sign in to comment.