-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
77 lines (59 loc) · 2.46 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# docker build . -t unigrid/paxd:latest
# docker run --name paxd --rm -it unigrid/paxd:latest /bin/sh
# docker cp paxd:/usr/bin/paxd /path/to/local/directory
# Use the Go alpine image as the base for the builder stage
FROM golang:1.21-alpine AS go-builder
SHELL ["/bin/sh", "-ecuxo", "pipefail"]
# Install necessary build dependencies
RUN apk add --no-cache ca-certificates build-base git
# Install gox for cross-compilation
RUN go install github.com/mitchellh/gox@latest
WORKDIR /code
# Display detailed list of all files and directories copied
RUN ls -la /code
# Specifically check for the .git directory
RUN if [ -d "/code/.git" ]; then \
echo ".git directory exists"; \
ls -la /code/.git; \
else \
echo ".git directory does NOT exist"; \
fi
# Add go.mod and go.sum to download and cache dependencies
ADD go.mod go.sum ./
# Dynamically determine the version of CosmWasm libwasmvm and download it
RUN set -eux; \
ARCH=$(uname -m); \
WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $2}'); \
if [ ! -z "${WASM_VERSION}" ]; then \
case ${ARCH} in \
x86_64) ARCHIVE_NAME="libwasmvm_muslc.x86_64.a" ;; \
aarch64) ARCHIVE_NAME="libwasmvm_muslc.aarch64.a" ;; \
*) echo "Unsupported architecture: ${ARCH}" exit 1 ;; \
esac; \
echo "Downloading ${ARCHIVE_NAME} for WASM_VERSION=${WASM_VERSION}"; \
DOWNLOAD_URL="https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/${ARCHIVE_NAME}"; \
echo "Download URL: ${DOWNLOAD_URL}"; \
wget -O /lib/${ARCHIVE_NAME} ${DOWNLOAD_URL}; \
fi; \
go mod download
# Copy the entire current directory to /code
COPY . /code/
# Build the project with static linking using the Makefile
# Ensure that the binary is statically linked
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build \
&& file /code/bin/paxd \
&& echo "Ensuring binary is statically linked ..." \
&& (file /code/bin/paxd | grep "statically linked")
# Start a new stage for the final image
FROM alpine:3.16
# Copy the built binary from the builder stage
COPY --from=go-builder /code/bin/paxd /usr/bin/paxd
# Copy the necessary scripts and configuration files
COPY docker/* /opt/
RUN chmod +x /opt/*.sh
COPY contracts/artifacts /opt/artifacts/
WORKDIR /opt
# Expose necessary ports (adjust these according to your application's needs)
EXPOSE 1317 26656 26657 9090
# Define the default command
CMD ["/usr/bin/paxd", "version"]