Skip to content

Commit

Permalink
create Containerfile and CI for it
Browse files Browse the repository at this point in the history
Signed-off-by: ozkanonur <[email protected]>
  • Loading branch information
onur-ozkan committed Jul 22, 2023
1 parent 40fae83 commit a3642c1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .container/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Compilation
FROM docker.io/library/golang:1.20.6-alpine as build
WORKDIR /app

COPY . .

RUN go build -ldflags "-s -w" package-search-api.go

# Runtime
FROM docker.io/library/debian:bullseye-slim

## Get binary
COPY --from=build /app/package-search-api /usr/local/bin/package-search-api

## Start the app
CMD ["package-search-api"]
22 changes: 22 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: container image
on: push

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
container-job:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build the container image
run: docker build --no-cache -t ozkanonur/package-search-api:latest -f .container/Containerfile .

- name: Push the container image
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/stable'
run: |
docker login --username ${{ secrets.DOCKER_HUB_USERNAME }} --password ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} docker.io
docker push ozkanonur/package-search-api:latest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
go.work

# binary
package_search_api
package-search-api

0 comments on commit a3642c1

Please sign in to comment.