-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
55 lines (45 loc) · 1.54 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
47
48
49
50
51
52
53
54
55
#
# terraswap-service
#
# build:
# docker build --force-rm -t REPO/terraswap-service .
# run:
# docker run --rm -it --env-file=path/to/.env --name terraswap-service -p 80:8080 REPO/terraswap-service
### BUILD
FROM golang:1.19-alpine AS build
WORKDIR /app
# Create appuser.
RUN adduser -D -g '' appuser
# Install required binaries
RUN apk add --update --no-cache zip git make build-base
# Copy app dependencies
COPY go.mod go.mod
COPY go.sum go.sum
COPY Makefile Makefile
# Download all golang package dependencies
RUN make deps
# Copy source files
COPY . .
# See https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a
RUN sha256sum /lib/libwasmvm_muslc.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479
# Build executable
## force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN go build -mod=readonly -tags "netgo muslc" -ldflags '-X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,muslc" -w -s' -trimpath -o ./main ./cmd/api
### RELEASE
FROM alpine:latest AS release
RUN apk add --update --no-cache gcc
WORKDIR /app
# Expose application port
# Import the user and group files to run the app as an unpriviledged user
COPY --from=build /etc/passwd /etc/passwd
# Use an unprivileged user
USER appuser
COPY --from=build /app/cmd /app/cmd
# Grab compiled binary from build
COPY --from=build /app/main /app/main
# Expose application port
ENV APP_PORT 8000
EXPOSE $APP_PORT
# Set entry point
CMD [ "./main" ]