forked from cloud-barista/cb-larva
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-service
41 lines (28 loc) · 1.26 KB
/
Dockerfile-service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## This is a Dockerfile for cb-network service
##############################################################
## Stage 1 - Go Build
##############################################################
FROM golang:1.19 AS builder
ENV GO111MODULE=on
COPY . /cb-larva
WORKDIR /cb-larva/poc-cb-net/cmd/service/
# Build the service
# Note - Using cgo write normal Go code that imports a pseudo-package "C". I may not need on cross-compiling.
# Note - You can find possible platforms by 'go tool dist list' for GOOS and GOARCH
# Note - Using the -ldflags parameter can help set variable values at compile time.
# Note - Using the -s and -w linker flags can strip the debugging information.
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-s -w' -o service
#############################################################
## Stage 2 - Application Setup
##############################################################
FROM alpine:latest
WORKDIR /app
RUN mkdir -p config
RUN mkdir -p docs
# Copy the execution file
COPY --from=builder /cb-larva/poc-cb-net/cmd/service/service .
# Copy the swagger.json for Swagger dashboard
COPY --from=builder /cb-larva/poc-cb-net/docs/cloud_barista_network.swagger.json ./docs/
# Ports for the cb-network service
EXPOSE 8053
ENTRYPOINT ["./service"]