gitlab.com/picnic-app/backend/role-api@v0.0.0-20230614140944-06a76ff3696d/Dockerfile (about)

     1  # syntax=docker/dockerfile:1
     2  
     3  ARG GOLANG_VERSION=1.20
     4  ARG ALPINE_VERSION=3.16
     5  
     6  
     7  ################
     8  # Build application
     9  FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS build
    10  
    11  WORKDIR /src
    12  
    13  RUN apk update && apk add make git
    14  
    15  COPY go.mod go.sum ./
    16  RUN --mount=type=secret,id=netrc,target=/root/.netrc go mod download
    17  
    18  COPY . .
    19  
    20  # Build binary
    21  RUN make build
    22  
    23  ################
    24  # Some binary external dependencies
    25  FROM alpine:${ALPINE_VERSION} as deps
    26  
    27  WORKDIR /src
    28  
    29  ARG WRENCH_VERSION=v1.1.0
    30  ARG LINKERD_AWAIT_VERSION=v0.2.7
    31  
    32  ADD https://github.com/cloudspannerecosystem/wrench/releases/download/${WRENCH_VERSION}/wrench_linux_amd64 ./wrench
    33  ADD https://github.com/linkerd/linkerd-await/releases/download/release%2F${LINKERD_AWAIT_VERSION}/linkerd-await-${LINKERD_AWAIT_VERSION}-amd64  ./linkerd-await
    34  
    35  RUN chmod +x wrench linkerd-await
    36  
    37  
    38  ################
    39  # Build target image
    40  FROM alpine:${ALPINE_VERSION}
    41  
    42  WORKDIR /app
    43  
    44  # Copy external binaries
    45  COPY --from=deps /src/wrench .
    46  COPY --from=deps /src/linkerd-await .
    47  
    48  # disable linkerd-await by default
    49  ENV LINKERD_AWAIT_DISABLED=1
    50  
    51  # Copy configuration
    52  COPY .cfg ./.cfg
    53  
    54  # Copy migration binary and migration files to target image
    55  COPY .db/spanner/migrate.sh .
    56  COPY .db/spanner/migrations/ ./migrations/
    57  RUN chmod +x ./migrate.sh
    58  
    59  # Copy app binary to target image
    60  COPY --from=build /src/bin/grpcapp .
    61  
    62  EXPOSE 8080
    63  EXPOSE 8082
    64  EXPOSE 8084
    65  
    66  CMD ["/app/grpcapp"]