diff --git a/.gitignore b/.gitignore index a99c97ca..91f51873 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ packages/ # Ignore IDE folders .idea/ .vscode/ +vendor/* +/vendor/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..b39ef6d6 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,61 @@ +variables: + GITLAB_IMAGE: registry.gitlab.com/oceanboltpub/tile38 + +stages: + - build + - push + +.build_images: &build_images + before_script: + - echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token registry.gitlab.com --password-stdin + - docker login -u _json_key --password-stdin https://eu.gcr.io < $GITLAB_DEPLOY_BOT_KEY + image: docker:19.03.0 + services: + - docker:19.03.0-dind + variables: + #DOCKER_HOST: tcp://localhost:2375 + DOCKER_TLS_DIR: "/certs" + DOCKER_DRIVER: overlay2 + stage: build + only: + - master + - development + - merge_requests + tags: + - docker + script: + - docker pull $GITLAB_IMAGE:$EDITION || true + - > + docker build + --build-arg VCS_REF=$CI_COMMIT_SHA + --build-arg VCS_URL=$CI_PROJECT_URL + --tag $GITLAB_IMAGE:$CI_COMMIT_SHA + . + - docker push $GITLAB_IMAGE + + +.push_master: &push_master + before_script: + - echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token registry.gitlab.com --password-stdin + - docker login -u _json_key --password-stdin https://eu.gcr.io < $GITLAB_DEPLOY_BOT_KEY + image: docker:19.03.0 + services: + - docker:19.03.0-dind + stage: push + only: + - master + variables: + # Again, we do not need the source code here. Just playing with Docker. + GIT_STRATEGY: none + #DOCKER_HOST: tcp://localhost:2375 + DOCKER_DRIVER: overlay2 + # Create the certificates inside this directory for both the server + # and client. The certificates used by the client will be created in + # /certs/client so we only need to share this directory with the + # volume mount in `config.toml`. + DOCKER_TLS_CERTDIR: "/certs" + script: + - docker pull $GITLAB_IMAGE:$CI_COMMIT_SHA + - docker tag $GITLAB_IMAGE:$CI_COMMIT_SHA $GITLAB_IMAGE:latest + - docker push $GITLAB_IMAGE:latest +# Here, the goal is to tag the "master" branch as "latest" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 18b164f2..2c015cfc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,21 @@ +FROM golang:1.13 as builder + +# Copy local code to the container image. +WORKDIR /tile38 +COPY . . +COPY ./cmd/tile38-server/main.go . + +# Build the command inside the container. +# (You may fetch or manage dependencies here, +# either manually or with a tool like "godep".) +RUN CGO_ENABLED=0 GOOS=linux go build -v -o tile38-server + FROM alpine:3.8 RUN apk add --no-cache ca-certificates -ADD tile38-server /usr/local/bin -ADD tile38-cli /usr/local/bin -ADD tile38-benchmark /usr/local/bin +COPY --from=builder /tile38/tile38-server /usr/local/bin/tile38-server +#ADD tile38-cli /usr/local/bin +#ADD tile38-benchmark /usr/local/bin RUN addgroup -S tile38 && \ adduser -S -G tile38 tile38 && \