Skip to content
Snippets Groups Projects
Commit 81c8baba authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

Dockerfile and adapted CI

parent 9fab0da1
Branches
Tags
3 merge requests!90Develop,!63Resolve "Dockerfile",!53V.0.1.0 Codename Threadbare
Pipeline #52958 failed
......@@ -3,7 +3,8 @@ variables:
stages:
- test
- documentation
- build
- deploy
before_script:
- git config --global url."https://$GO_MODULES_USER:$GO_MODULES_ACCESS_TOKEN@code.fbi.h-da.de".insteadOf "https://code.fbi.h-da.de"
......@@ -12,3 +13,4 @@ include:
- local: '/build/ci/.code-quality-ci.yml'
- local: '/build/ci/.documentation-ci.yml'
- local: '/build/ci/.security-and-compliance-ci.yml'
- local: '/build/ci/.build-container.yml'
\ No newline at end of file
FROM golang:alpine AS builder
ARG GITLAB_USER
ARG GITLAB_TOKEN
WORKDIR /src/gosdn
COPY . .
RUN git config --global url."https://$GITLAB_USER:$GITLAB_TOKEN@code.fbi.h-da.de".insteadOf "https://code.fbi.h-da.de"
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build ./cmd/gosdn
FROM alpine:latest
EXPOSE 8443
COPY --from=builder /src/gosdn/gosdn .
COPY --from=builder /src/gosdn/config .
ENTRYPOINT [ "./gosdn" ]
CMD [""]
variables:
DOCKER_IMAGE_SHA: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
build:docker:
stage: build
tags:
- baremetal
script:
- >
docker build \
--build-arg <GITLAB_USER>=<$GO_MODULES_USER> \
--build-arg <GITLAB_TOKEN>=<$GO_MODULES_ACCESS_TOKEN> \
-t $DOCKER_IMAGE_SHA .
.deploy: &deploy
stage: deploy
needs: ["build:docker"]
tags:
- baremetal
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker tag $DOCKER_IMAGE_SHA $TAG
- docker push $TAG
deploy:develop:
variables:
TAG: $CI_REGISTRY_IMAGE:develop
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
<<: *deploy
deploy:tagged:
variables:
TAG: $CI_REGISTRY_IMAGE:CI_COMMIT_TAG
rules:
- if: CI_COMMIT_TAG
<<: *deploy
deploy:latest:
variables:
TAG: $CI_REGISTRY_IMAGE:latest
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
<<: *deploy
\ No newline at end of file
......@@ -5,7 +5,7 @@ documentation:pdf:
name: pandoc/latex
entrypoint:
- ''
stage: documentation
stage: deploy
rules:
- changes:
- documentation/design/*.md
......@@ -22,7 +22,7 @@ documentation:pdf:
- cargo install mdbook
image:
name: rust:latest
stage: documentation
stage: deploy
script:
- mdbook build documentation --dest-dir public
cache:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment