2022-08-03 23:37:26 +03:00
|
|
|
FROM golang:alpine as builder
|
|
|
|
|
|
|
|
|
|
LABEL org.opencontainers.image.authors="psssix <psssix@gmail.com>"
|
|
|
|
|
|
|
|
|
|
# Build Delve
|
|
|
|
|
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
|
|
|
|
|
|
|
|
|
# set build environmet variables needed for multistage building
|
|
|
|
|
ENV CGO_ENABLED=0 \
|
|
|
|
|
GOOS=linux
|
|
|
|
|
|
|
|
|
|
# source workdir
|
|
|
|
|
WORKDIR /source
|
|
|
|
|
|
|
|
|
|
# Copy and download dependency using go mod
|
|
|
|
|
# Vendoring
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
|
|
# Copy the code into the container
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# Build the application
|
2022-08-07 23:21:08 +03:00
|
|
|
RUN go build -gcflags="all=-N -l" -o bin/app .
|
2022-08-03 23:37:26 +03:00
|
|
|
|
|
|
|
|
FROM alpine:latest
|
|
|
|
|
|
|
|
|
|
# Add entrypoint dependency
|
2022-08-07 00:20:37 +03:00
|
|
|
RUN apk add --no-cache bash
|
|
|
|
|
#RUN apk add --no-cache mysql-client mariadb-connector-c
|
2022-08-03 23:37:26 +03:00
|
|
|
|
2022-08-07 00:20:37 +03:00
|
|
|
# Move to /app directory as the place for resulting binary folder
|
2022-08-03 23:37:26 +03:00
|
|
|
WORKDIR /
|
|
|
|
|
|
|
|
|
|
# Copy binary from build to main folder
|
|
|
|
|
COPY --from=builder /go/bin/dlv .
|
2022-08-07 23:21:08 +03:00
|
|
|
COPY --from=builder /source/bin/app app
|
2022-08-03 23:37:26 +03:00
|
|
|
|
|
|
|
|
# Copy some application assets
|
2022-08-07 00:20:37 +03:00
|
|
|
COPY --from=builder /source/deploy/docker/environment.sh ./deploy/docker/environment.sh
|
|
|
|
|
COPY --from=builder /source/deploy/docker/logging.sh ./deploy/docker/logging.sh
|
2022-08-03 23:37:26 +03:00
|
|
|
COPY --from=builder /source/entrypoint.sh .
|
|
|
|
|
#COPY --from=builder /source/migrations ./migrations
|
|
|
|
|
#COPY ./database/data.json /database/data.json
|
|
|
|
|
|
|
|
|
|
# Export necessary port
|
|
|
|
|
EXPOSE 4040
|
|
|
|
|
|
2022-08-07 00:20:37 +03:00
|
|
|
# entry and start entrypoint with some actions and checks before CMD
|
2022-08-03 23:37:26 +03:00
|
|
|
ENTRYPOINT ["bash", "/entrypoint.sh" ]
|
|
|
|
|
|
|
|
|
|
# Command to run when starting the container
|
|
|
|
|
CMD ["/dlv", "--listen=:4040", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/app"]
|