Add CI job building the binary and a docker image

This commit is contained in:
Felix Auringer
2021-04-26 15:36:24 +02:00
parent e14e9c9229
commit 2cb34eb477
2 changed files with 42 additions and 0 deletions

View File

@ -2,8 +2,26 @@ default:
image: golang:latest image: golang:latest
stages: stages:
- build
- lint - lint
- test - test
- docker
variables:
DOCKER_TLS_CERTDIR: ""
IMAGE_NAME: $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME/$CI_COMMIT_REF_SLUG:latest
compile:
stage: build
needs: []
variables:
CGO_ENABLED: 0
script:
- go build -o poseidon
artifacts:
paths:
- poseidon
expire_in: 1 week
golangci-lint: golangci-lint:
stage: lint stage: lint
@ -24,3 +42,19 @@ test:
needs: [] needs: []
script: script:
- go test ./... -v - go test ./... -v
dockerimage:
stage: docker
image: docker:latest
services:
- name: docker:dind
alias: docker
needs:
- compile
script:
- docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY
# Prevent pull rate limit but still have normal alpine image in Dockerfile
- docker pull $DOCKER_REGISTRY/library/alpine:latest
- docker tag $DOCKER_REGISTRY/library/alpine:latest alpine:latest
- docker build -t $IMAGE_NAME .
- docker push $IMAGE_NAME

8
Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM alpine:latest
RUN adduser --disabled-password api
USER api
COPY poseidon /home/api/
EXPOSE 3000
CMD ["/home/api/poseidon"]