-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
46 lines (33 loc) · 1.18 KB
/
Dockerfile
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
42
43
44
45
46
###############################################################################
# Build image
###############################################################################
ARG UBUNTU_VER
FROM ubuntu:${UBUNTU_VER:-22.04} AS builder
ARG TARGETARCH
ARG TARGETOS
ARG GO_VER
ARG APP_VER=unknown
RUN apt update && apt install -y \
git \
gcc \
curl \
make
RUN curl -sL https://go.dev/dl/go${GO_VER}.${TARGETOS}-${TARGETARCH}.tar.gz | tar zxf - -C /usr/local
ENV PATH="/usr/local/go/bin:$PATH"
ADD . .
RUN CGO_ENABLED=0 go build -v -o /go/bin/chaincode
###############################################################################
# Runtime image
###############################################################################
ARG UBUNTU_VER
FROM ubuntu:${UBUNTU_VER:-22.04}
ARG APP_VER
# set up nsswitch.conf for Go's "netgo" implementation
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
ENV APP_VER=${APP_VER}
ENV CHAINCODE_EXEC_MODE=server
COPY --chown=65534:65534 --from=builder /go/bin/chaincode /
USER 65534
ENTRYPOINT [ "/chaincode" ]