Skip to content

Commit

Permalink
feat: added workflow and modified dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
rlardy-ulule committed Oct 17, 2023
1 parent 943aca5 commit 31c399c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 10 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/geoipfix.yml
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
33 changes: 23 additions & 10 deletions Dockerfile
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"]

0 comments on commit 31c399c

Please sign in to comment.