diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0027949..81e3bfd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,8 +2,26 @@ default: image: golang:latest stages: + - build - lint - 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: stage: lint @@ -24,3 +42,19 @@ test: needs: [] script: - 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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..75b0eec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM alpine:latest + +RUN adduser --disabled-password api +USER api +COPY poseidon /home/api/ + +EXPOSE 3000 +CMD ["/home/api/poseidon"]