-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from thoughtgears/feature/multiple-proxies
addded a workflow to build dockerfile
- Loading branch information
Showing
5 changed files
with
119 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Publish Docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
IMAGE_NAME: proximo | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=sha | ||
- name: Set outputs | ||
id: vars | ||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
GIT_REPO=${{ github.repository }} | ||
GIT_COMMIT=${{ steps.vars.outputs.short_sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
########################### | ||
# Build container for app # | ||
########################### | ||
|
||
# Build arg VERSION only works before the FROM statement | ||
ARG VERSION=latest | ||
FROM golang:${VERSION} AS builder | ||
|
||
# Sets build args for container | ||
ARG SERVICE_NAME | ||
ARG GIT_COMMIT | ||
ARG GIT_REPO | ||
|
||
# Set proper workdir for build | ||
WORKDIR /go/src/github.com/${GIT_REPO} | ||
|
||
# Copy, get all packages and build application | ||
COPY . . | ||
RUN go mod tidy && \ | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-X main.Version=${GIT_COMMIT}" -o ./builds/${SERVICE_NAME}-linux-amd64 | ||
|
||
############################## | ||
# Deployment container build # | ||
############################## | ||
|
||
FROM alpine:latest | ||
# Sets build args for container | ||
ARG GIT_REPO | ||
ARG SERVICE_NAME | ||
|
||
# Install Root Certificates for https endpoints | ||
RUN apk update | ||
RUN apk --no-cache add ca-certificates | ||
|
||
# Set workdir for app and copy from the builder image | ||
WORKDIR /root/ | ||
COPY --from=builder /go/src/github.com/${GIT_REPO}/builds/${SERVICE_NAME}-linux-amd64 ./app | ||
ENTRYPOINT ["./app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters