mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2024-12-22 16:37:59 +00:00
parent
c0d1143de6
commit
36f82eb6a7
42
.github/workflows/main.yml
vendored
Normal file
42
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: install go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.17
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
run: make lint
|
||||||
|
|
||||||
|
- name: Tests
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: tests
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set env
|
||||||
|
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Sign in to dockerhub
|
||||||
|
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
||||||
|
|
||||||
|
- name: Deploy image
|
||||||
|
run: make docker-build VERSION=$RELEASE_VERSION
|
@ -1,10 +1,13 @@
|
|||||||
FROM golang:1.17-alpine as builder
|
FROM golang:1.17-alpine as builder
|
||||||
|
|
||||||
|
ARG ARG_VERSION
|
||||||
|
ENV VERSION $ARG_VERSION
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN apk add make && make build
|
RUN apk add make && make build VERSION=$VERSION
|
||||||
|
|
||||||
# Build final image
|
# Build final image
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
17
Makefile
17
Makefile
@ -33,13 +33,24 @@ build:
|
|||||||
|
|
||||||
.PHONY: docker-build
|
.PHONY: docker-build
|
||||||
docker-build:
|
docker-build:
|
||||||
docker build --tag ${DOCKER_URL}:${VERSION} .
|
docker build --build-arg=ARG_VERSION="${VERSION}" --tag ${DOCKER_URL}:${VERSION} .
|
||||||
|
|
||||||
|
.PHONY: docker-push
|
||||||
|
docker-push: docker-build
|
||||||
|
ifneq (,$(findstring devel-,$(VERSION)))
|
||||||
|
@echo "VERSION is set to ${VERSION}, I can't push devel builds"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
docker push ${DOCKER_URL}:${VERSION}
|
||||||
|
docker tag ${DOCKER_URL}:${VERSION} ${DOCKER_URL}:latest
|
||||||
|
docker push ${DOCKER_URL}:latest
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: docker-run
|
.PHONY: docker-run
|
||||||
docker-run: docker-build
|
docker-run: docker-build
|
||||||
docker run --tty --interactive --rm \
|
docker run --tty --interactive --rm \
|
||||||
-v $$PWD/test/GeoIP2-City-Test.mmdb:/tmp/GeoIP2-City-Test.mmdb:ro \
|
-v ${PWD}/test/GeoIP2-City-Test.mmdb:/tmp/GeoIP2-City-Test.mmdb:ro \
|
||||||
-v $$PWD/test/GeoLite2-ASN-Test.mmdb:/tmp/GeoLite2-ASN-Test.mmdb:ro -p 8080:8080 \
|
-v ${PWD}/test/GeoLite2-ASN-Test.mmdb:/tmp/GeoLite2-ASN-Test.mmdb:ro -p 8080:8080 \
|
||||||
${DOCKER_URL}:${VERSION} \
|
${DOCKER_URL}:${VERSION} \
|
||||||
-geoip2-city /tmp/GeoIP2-City-Test.mmdb \
|
-geoip2-city /tmp/GeoIP2-City-Test.mmdb \
|
||||||
-geoip2-asn /tmp/GeoLite2-ASN-Test.mmdb \
|
-geoip2-asn /tmp/GeoLite2-ASN-Test.mmdb \
|
||||||
|
Loading…
Reference in New Issue
Block a user