This commit is contained in:
Jack Harley 2023-02-22 16:18:51 +00:00
commit d7373d0522
6 changed files with 54 additions and 0 deletions

11
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,11 @@
build:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG --destination $CI_REGISTRY_IMAGE:latest
rules:
- if: $CI_COMMIT_TAG

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM golang:1.20-alpine as builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o main .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root
COPY --from=builder /app/main .
ENTRYPOINT ["./main"]

6
Dockerfile.debug Normal file
View File

@ -0,0 +1,6 @@
FROM golang:1.20
RUN apt-get update && apt-get install dumb-init
RUN go install github.com/go-delve/delve/cmd/dlv@latest
WORKDIR /app
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "debug", "--build-flags=-buildvcs=false", "--continue"]

5
Dockerfile.dev Normal file
View File

@ -0,0 +1,5 @@
FROM golang:1.20-alpine
RUN apk --no-cache add dumb-init
WORKDIR /app
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["go", "run", "main.go"]

13
docker-compose.debug.yml Normal file
View File

@ -0,0 +1,13 @@
services:
myapp:
build:
context: .
dockerfile: Dockerfile.debug
security_opt:
- seccomp:unconfined
cap_add:
- SYS_PTRACE
ports:
- "40000:40000"
volumes:
- .:/app

7
docker-compose.yml Normal file
View File

@ -0,0 +1,7 @@
services:
myapp:
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- .:/app