diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 2e741f0..cfeece8 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -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' }} @@ -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 }} diff --git a/backend.Dockerfile b/backend.Dockerfile index 1dada34..efc057e 100644 --- a/backend.Dockerfile +++ b/backend.Dockerfile @@ -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 @@ -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"] - diff --git a/frontend.Dockerfile b/frontend.Dockerfile index 79c4b5d..2f6c68d 100644 --- a/frontend.Dockerfile +++ b/frontend.Dockerfile @@ -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