Compare commits

..

No commits in common. "dev/ci-docker-builder" and "master" have entirely different histories.

9 changed files with 60 additions and 124 deletions

View File

@ -4,63 +4,31 @@ name: default
steps: steps:
- name: static_check - name: static_check
image: golang:1.18 image: golang:1.16
commands: commands:
- go install honnef.co/go/tools/cmd/staticcheck@latest - go get honnef.co/go/tools/cmd/staticcheck
- staticcheck ./pkg/... - staticcheck ./pkg/...
volumes: volumes:
- name: gopath - name: gopath
path: /go path: /go
- name: lint - name: lint
image: golang:1.18 image: golang:1.16
commands: commands:
- go install golang.org/x/lint/golint@latest - go get golang.org/x/lint/golint
- golint -set_exit_status ./pkg/... - golint -set_exit_status ./pkg/...
volumes: volumes:
- name: gopath - name: gopath
path: /go path: /go
- name: vet - name: vet
image: golang:1.18 image: golang:1.16
commands: commands:
- go vet ./pkg/... - go vet ./pkg/...
volumes: volumes:
- name: gopath - name: gopath
path: /go path: /go
- name: build_image
image: plugins/docker
commands:
- sleep 5
- ./deploy/build_image.sh
volumes:
- name: docker-sock
path: /var/run
- name: push_image
image: plugins/docker
environment:
DOCKER_USERNAME:
from_secret: registry_username
DOCKER_PASSWORD:
from_secret: registry_password
commands:
- ./deploy/publish_image.sh
volumes:
- name: docker-sock
path: /var/run
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: docker-sock
path: /var/run
volumes: volumes:
- name: gopath - name: gopath
temp: {} temp: {}
- name: docker-sock
temp: {}

2
.gitignore vendored
View File

@ -1,4 +1,2 @@
.idea/
vegvisir.json vegvisir.json
*.prof *.prof

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM golang:1.16-alpine
RUN mkdir /go/src/vegvisir
WORKDIR /go/src/vegvisir
COPY vegvisir.json go.mod go.sum ./
COPY pkg/ ./pkg
RUN go mod download
CMD ["go", "run", "pkg/main.go"]

View File

@ -1,22 +0,0 @@
# Builder
FROM golang:alpine AS builder
WORKDIR /go/src/app
ARG MAIN_GO=pkg/main.go
# ARG HTTP_PORT=8080
# ENV HTTP_PORT {$HTTP_PORT}
COPY go.mod go.sum ./
COPY pkg ./pkg
RUN go mod download && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/app $MAIN_GO
# Destination image
FROM gcr.io/distroless/base-debian10
COPY --from=builder /go/bin/app /app
EXPOSE $HTTP_PORT
ENTRYPOINT ["/app"]

View File

@ -1,11 +0,0 @@
FROM golang:alpine
# RUN mkdir /go/src/app
WORKDIR /go/src/app
COPY go.mod go.sum ./
COPY pkg ./
RUN go mod download
ENTRYPOINT ["go", "run", "pkg/main.go"]

View File

@ -1,15 +0,0 @@
#!/bin/sh
set -e
set -x
# BRANCH="dev/ci-docker-builder"
# BRANCH="develop"
# BRANCH=$CI_COMMIT_BRANCH
branch=$(echo $CI_COMMIT_BRANCH | grep -v /) || echo $CI_COMMIT_BRANCH ;
p1=$(echo $CI_COMMIT_BRANCH | cut -d / -f1 -s) &&
p2=$(echo $CI_COMMIT_BRANCH | cut -d / -f2 -s) &&
tag=${branch:=$p1-$p2} &&
echo "Building" $tag
docker build -t git.pbiernat.dev/golang/vegvisir:$tag -f deploy/Dockerfile.build .

View File

@ -1,17 +0,0 @@
#!/bin/sh
set -e
set -x
# BRANCH="dev/ci-docker-builder"
# BRANCH="develop"
# BRANCH=$CI_COMMIT_BRANCH
branch=$(echo $CI_COMMIT_BRANCH | grep -v /) || echo $CI_COMMIT_BRANCH ;
p1=$(echo $CI_COMMIT_BRANCH | cut -d / -f1 -s) &&
p2=$(echo $CI_COMMIT_BRANCH | cut -d / -f2 -s) &&
tag=${branch:=$p1-$p2} &&
echo "Publishing" $tag
echo $DOCKER_PASSWORD | docker login git.pbiernat.dev -u $DOCKER_USERNAME --password-stdin &&
docker push git.pbiernat.dev/golang/vegvisir:$tag

43
vegvisir.json Normal file
View File

@ -0,0 +1,43 @@
{
"server": {
"address": "127.0.0.1",
"port": 8080
},
"backends": {
"news-app": {
"prefixURL": "news/",
"backendAddress": "http://172.17.0.1:3030",
"routes": [{
"pattern": "new/(.*)/([0-9]*)",
"target": "new-url/$1/$2"
},{
"pattern": "new/(.*)",
"target": "$1"
},{
"pattern": "(.+)",
"target": "url"
}]
},
"article-app": {
"prefixURL": "art/",
"backendAddress": "http://172.17.0.1:3030",
"routes": [{
"pattern": "art1/(.*)",
"target": "art-url/$1"
},{
"pattern": "([a-zA-Z0-9]*)",
"target": "art-global/$1"
}]
}
},
"cache": {
"type": "redis",
"host": "localhost",
"port": 6379,
"username": "",
"password": "",
"database": "0",
"routeTTL": 10,
"responseTTL": 10
}
}

View File

@ -1,19 +0,0 @@
{
"server": {
"address": "127.0.0.1",
"port": 8080
},
"backends": {
"dummy-app": {
"prefixURL": "/",
"backendAddress": "http://172.17.0.1:80",
"routes": [{
"pattern": "(.+)",
"target": "$1"
}]
}
},
"cache": {
"type": "memory"
}
}