Skip to content

Commit

Permalink
Merge pull request #92 from multiversx/MX-16127-Chain-simulator-docke…
Browse files Browse the repository at this point in the history
…r-multi-platform-build

Updated workflow and Dockerfile for multi-platform build.
  • Loading branch information
danidrasovean authored Nov 18, 2024
2 parents a585c20 + ce0e766 commit 3dbecfe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Publish Docker image
on:
release:
types: [published]
pull_request:

jobs:
push_to_registry:
Expand All @@ -17,7 +18,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.20.7
id: go
Expand All @@ -29,31 +30,37 @@ jobs:
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build and run chain simulator to fetch configs
run: |
cd cmd/chainsimulator
go build
./chainsimulator --fetch-configs-and-close
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
uses: docker/metadata-action@v5
with:
images: multiversx/chainsimulator

- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'release' && github.event.action == 'published' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.7 as builder
FROM golang:1.20.7 AS builder


WORKDIR /multiversx
Expand All @@ -10,11 +10,17 @@ WORKDIR /multiversx/cmd/chainsimulator

RUN go build -o chainsimulator

RUN cp /go/pkg/mod/github.com/multiversx/$(cat /multiversx/go.sum | grep mx-chain-vm-v | sort -n | tail -n -1| awk -F '/' '{print$3}'| sed 's/ /@/g')/wasmer/libwasmer_linux_amd64.so /lib/libwasmer_linux_amd64.so
RUN cp /go/pkg/mod/github.com/multiversx/$(cat /multiversx/go.sum | grep mx-chain-vm-go | sort -n | tail -n -1| awk -F '/' '{print$3}'| sed 's/ /@/g')/wasmer2/libvmexeccapi.so /lib/libvmexeccapi.so
RUN mkdir -p /lib_amd64 /lib_arm64

RUN cp /go/pkg/mod/github.com/multiversx/$(cat /multiversx/go.sum | grep mx-chain-vm-v | sort -n | tail -n -1 | awk -F '/' '{print$3}' | sed 's/ /@/g')/wasmer/libwasmer_linux_amd64.so /lib_amd64/
RUN cp /go/pkg/mod/github.com/multiversx/$(cat /multiversx/go.sum | grep mx-chain-vm-go | sort -n | tail -n -1 | awk -F '/' '{print$3}' | sed 's/ /@/g')/wasmer2/libvmexeccapi.so /lib_amd64/

RUN cp /go/pkg/mod/github.com/multiversx/$(cat /multiversx/go.sum | grep mx-chain-vm-v | sort -n | tail -n -1 | awk -F '/' '{print$3}' | sed 's/ /@/g')/wasmer/libwasmer_linux_arm64_shim.so /lib_arm64/
RUN cp /go/pkg/mod/github.com/multiversx/$(cat /multiversx/go.sum | grep mx-chain-vm-go | sort -n | tail -n -1 | awk -F '/' '{print$3}' | sed 's/ /@/g')/wasmer2/libvmexeccapi_arm.so /lib_arm64/


FROM ubuntu:22.04
ARG TARGETARCH

RUN apt-get update \
&& apt-get -y install git \
Expand All @@ -26,11 +32,11 @@ EXPOSE 8085

WORKDIR /multiversx

COPY --from=builder "/lib/libwasmer_linux_amd64.so" "/lib/libwasmer_linux_amd64.so"
COPY --from=builder "/lib/libvmexeccapi.so" "/lib/libvmexeccapi.so"
# Copy architecture-specific files
COPY --from=builder "/lib_${TARGETARCH}/*" "/lib/"

RUN apt-get update && apt-get install -y curl
CMD /bin/bash
CMD ["/bin/bash"]

ENTRYPOINT ["./chainsimulator"]

Expand Down

0 comments on commit 3dbecfe

Please sign in to comment.