-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added workflow and modified dockerfile
- Loading branch information
1 parent
943aca5
commit 31c399c
Showing
2 changed files
with
70 additions
and
10 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,47 @@ | ||
name: Ulule-geoipfix | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- '.github/**' | ||
branches-ignore: | ||
- main | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
||
|
||
jobs: | ||
build: | ||
timeout-minutes: 30 | ||
runs-on: [self-hosted, linux, x64] | ||
|
||
steps: | ||
- name: Checking out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to GCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ vars.REGISTRY }} | ||
username: _json_key | ||
password: ${{ secrets.GCR_JSON_KEY }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Removing slashes from branch name when not tag or dev branch | ||
id: git_tag | ||
run: | | ||
echo "GIT_TAG=${GIT_TAG//\//-}" >> "$GITHUB_OUTPUT" | ||
env: | ||
GIT_TAG: ${{ github.ref_name }} | ||
|
||
- name: Build app and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: ${{ vars.REGISTRY }}/ulule-geoipfix:${{ github.sha }},${{ vars.REGISTRY }}/ulule-geoipfix:${{ steps.git_tag.outputs.GIT_TAG }} | ||
cache-from: type=registry,ref=${{ vars.REGISTRY }}/ulule-geoipfix:cache | ||
cache-to: type=registry,ref=${{ vars.REGISTRY }}/ulule-geoipfix:cache,mode=max |
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 |
---|---|---|
@@ -1,14 +1,27 @@ | ||
FROM debian:stretch-slim | ||
FROM golang:1.21-alpine AS geoipfix-builder | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y wget | ||
ARG GIT_COMMIT | ||
ARG GIT_BRANCH | ||
|
||
RUN mkdir -p /usr/share/geoip \ | ||
&& wget -O /tmp/GeoLite2-City.tar.gz http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz \ | ||
&& tar xf /tmp/GeoLite2-City.tar.gz -C /usr/share/geoip --strip 1 \ | ||
&& gzip /usr/share/geoip/GeoLite2-City.mmdb \ | ||
&& ls -al /usr/share/geoip/ | ||
WORKDIR /app | ||
|
||
ADD bin/geoipfix /geoipfix | ||
COPY . . | ||
|
||
CMD ["/geoipfix"] | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
CGO_ENABLED=0 go build -ldflags "\ | ||
-X 'github.com/ulule/geoipfix.Branch=${GIT_BRANCH})' \ | ||
-X 'github.com/ulule/geoipfix.Revision=${GIT_COMMIT}' \ | ||
-X 'github.com/ulule/geoipfix.Compiler=$(go version)'" -a -installsuffix cgo -o /geoipfix ./cmd/main.go | ||
|
||
#FROM alpine | ||
FROM scratch | ||
|
||
# RUN addgroup -S chouette && \ | ||
# adduser -S chouette -G chouette && \ | ||
# apk add --no-cache ca-certificates | ||
|
||
# USER chouette:chouette | ||
|
||
COPY --from=geoipfix-builder /geoipfix /geoipfix | ||
|
||
ENTRYPOINT ["/geoipfix"] |