Skip to content

Commit c33b74d

Browse files
Merge pull request #19 from multiversx/update-feb2026
Update devcontainer image
2 parents 3899f5d + 127e407 commit c33b74d

5 files changed

Lines changed: 189 additions & 97 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
env:
2+
IMAGE_NAME: devcontainer-smart-contracts-rust
3+
REGISTRY_HOSTNAME: multiversx
4+
5+
name: Build Docker image - rust (PR)
6+
7+
on:
8+
pull_request:
9+
10+
jobs:
11+
build-docker-image:
12+
strategy:
13+
matrix:
14+
runner: [ubuntu-latest, ubuntu-24.04-arm]
15+
runs-on: ${{ matrix.runner }}
16+
17+
steps:
18+
- name: Check out the repo
19+
uses: actions/checkout@v5
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Build image
25+
uses: docker/build-push-action@v6
26+
with:
27+
context: ./resources/smart-contracts-rust
28+
push: false
29+
file: ./resources/smart-contracts-rust/Dockerfile
30+
tags: ${{ env.REGISTRY_HOSTNAME }}/${{ env.IMAGE_NAME }}:pr-test

.github/workflows/publish-image-rust.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
env:
2+
IMAGE_NAME: devcontainer-smart-contracts-rust
3+
REGISTRY_HOSTNAME: multiversx
4+
5+
name: Publish Docker image - rust (release)
6+
7+
on:
8+
release:
9+
types: [published]
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: 'Simulate release version (e.g., v0.4.2)'
14+
required: false
15+
default: ''
16+
type: string
17+
18+
jobs:
19+
prepare:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
tags: ${{ steps.meta.outputs.tags }}
23+
tags-json: ${{ steps.meta.outputs.json }}
24+
labels: ${{ steps.meta.outputs.labels }}
25+
steps:
26+
- name: Check out the repo
27+
uses: actions/checkout@v4
28+
29+
- name: Compute version from template (release)
30+
id: version
31+
if: github.event_name == 'release'
32+
run: |
33+
VERSION=v$(jq -r '.["version"]' ./src/smart-contracts-rust/devcontainer-template.json)
34+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
35+
36+
- name: Extract metadata
37+
id: meta
38+
env:
39+
VERSION: ${{ steps.version.outputs.VERSION }}
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY_HOSTNAME }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=raw,value=latest
45+
${{ (github.event_name == 'release' && format('type=raw,value={0}', env.VERSION)) || (github.event.inputs.version != '' && format('type=raw,value={0}', github.event.inputs.version)) || '' }}
46+
47+
build:
48+
strategy:
49+
matrix:
50+
arch:
51+
- { runner: ubuntu-latest, platform: linux/amd64, platform_tag: linux_amd64 }
52+
- { runner: ubuntu-24.04-arm, platform: linux/arm64, platform_tag: linux_arm64 }
53+
runs-on: ${{ matrix.arch.runner }}
54+
needs: prepare
55+
steps:
56+
- name: Check out the repo
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@v3
61+
62+
- name: Log in to Docker Hub
63+
uses: docker/login-action@v3
64+
with:
65+
username: ${{ secrets.DOCKER_USERNAME }}
66+
password: ${{ secrets.DOCKER_PASSWORD }}
67+
68+
- name: Build and push by digest
69+
id: build
70+
uses: docker/build-push-action@v6
71+
with:
72+
context: ./resources/smart-contracts-rust
73+
file: ./resources/smart-contracts-rust/Dockerfile
74+
platforms: ${{ matrix.arch.platform }}
75+
labels: ${{ needs.prepare.outputs.labels }}
76+
outputs: type=image,name=${{ env.REGISTRY_HOSTNAME }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
77+
78+
- name: Export digest
79+
run: |
80+
mkdir -p /tmp/digests
81+
digest="${{ steps.build.outputs.digest }}"
82+
touch "/tmp/digests/${digest#sha256:}"
83+
84+
- name: Upload digest
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: digests-${{ matrix.arch.platform_tag }}
88+
path: /tmp/digests/*
89+
if-no-files-found: error
90+
retention-days: 1
91+
92+
manifest:
93+
runs-on: ubuntu-latest
94+
needs: [prepare, build]
95+
96+
steps:
97+
- name: Download digests
98+
uses: actions/download-artifact@v4
99+
with:
100+
path: /tmp/digests
101+
pattern: digests-*
102+
merge-multiple: true
103+
104+
- name: Set up Docker Buildx
105+
uses: docker/setup-buildx-action@v3
106+
107+
- name: Log in to Docker Hub
108+
uses: docker/login-action@v3
109+
with:
110+
username: ${{ secrets.DOCKER_USERNAME }}
111+
password: ${{ secrets.DOCKER_PASSWORD }}
112+
113+
- name: Create and push manifest
114+
working-directory: /tmp/digests
115+
env:
116+
TAGS_JSON: ${{ needs.prepare.outputs.tags-json }}
117+
run: |
118+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$TAGS_JSON") \
119+
$(printf '${{ env.REGISTRY_HOSTNAME }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,59 @@
1-
FROM ubuntu:22.04
1+
FROM ubuntu:24.04
22

3-
ARG USERNAME=developer
4-
ARG USER_UID=1000
5-
ARG USER_GID=$USER_UID
3+
ARG USERNAME=ubuntu
4+
ARG VERSION_MXPY="11.3.1"
5+
ARG VERSION_RUST="1.90.0"
6+
ARG VERSION_SC_META="0.64.2"
67

7-
ARG VERSION_MXPY="v11.1.1"
8-
ARG VERSION_RUST="1.86.0"
9-
ARG VERSION_SC_META="0.62.0"
8+
ENV DEBIAN_FRONTEND=noninteractive
109

11-
# Create the user
12-
RUN groupadd --gid $USER_GID $USERNAME \
13-
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
14-
#
15-
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
16-
&& apt-get update \
17-
&& apt-get install -y sudo \
18-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
19-
&& chmod 0440 /etc/sudoers.d/$USERNAME
20-
21-
# Install some dependencies as root
10+
# Base system dependencies
2211
RUN apt-get update && apt-get install -y \
23-
wget \
24-
build-essential \
25-
python3.10 python3-pip python3.10-venv \
12+
sudo \
13+
curl \
2614
git \
15+
build-essential \
2716
pkg-config \
28-
libssl-dev && \
29-
rm -rf /var/lib/apt/lists/*
30-
31-
# Switch to regular user
32-
USER $USERNAME
17+
libssl-dev \
18+
python3 \
19+
python3-venv \
20+
python3-pip \
21+
pipx \
22+
ca-certificates \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
# Give sudo access to the user without password
26+
RUN echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
27+
&& chmod 0440 /etc/sudoers.d/${USERNAME}
28+
29+
USER ${USERNAME}
3330
WORKDIR /home/${USERNAME}
3431

32+
# Environment variables
3533
ENV MULTIVERSX="/home/${USERNAME}/multiversx-sdk"
3634
ENV PATH="/home/${USERNAME}/.local/bin:${PATH}"
3735
ENV PATH="/home/${USERNAME}/.cargo/bin:${PATH}"
3836

39-
# Install pipx
40-
RUN python3 -m pip install --no-cache-dir --user pipx
41-
42-
# Install mxpy
37+
# Install mxpy via pipx
4338
RUN pipx install multiversx-sdk-cli==${VERSION_MXPY}
4439

45-
# Install rust
46-
RUN wget -O rustup.sh https://sh.rustup.rs && \
47-
chmod +x rustup.sh && \
48-
CARGO_HOME=/home/${USERNAME}/.cargo RUSTUP_HOME=/home/${USERNAME}/.rustup ./rustup.sh --verbose --default-toolchain ${VERSION_RUST} --profile minimal -y && \
49-
rm rustup.sh
40+
# Install Rust
41+
RUN curl https://sh.rustup.rs -sSf | \
42+
sh -s -- -y --profile minimal --default-toolchain ${VERSION_RUST}
5043

5144
# Install sc-meta tools
52-
RUN CARGO_HOME=/home/${USERNAME}/.cargo RUSTUP_HOME=/home/${USERNAME}/.rustup PATH="/home/${USERNAME}/.cargo/bin:${PATH}" \
53-
cargo install multiversx-sc-meta --version ${VERSION_SC_META} --locked
54-
55-
RUN CARGO_HOME=/home/${USERNAME}/.cargo RUSTUP_HOME=/home/${USERNAME}/.rustup PATH="/home/${USERNAME}/.cargo/bin:${PATH}" \
56-
sc-meta install all
45+
RUN cargo install multiversx-sc-meta --version ${VERSION_SC_META} --locked \
46+
&& sc-meta install all
5747

5848
# Install test wallets
59-
RUN mxpy deps install testwallets && rm ${MULTIVERSX}/*.tar.gz
49+
RUN mxpy deps install testwallets
50+
51+
# Rust components + cleanup
52+
RUN rustup component add rustfmt \
53+
&& rm -rf /home/${USERNAME}/.cargo/registry \
54+
&& rm -rf /home/${USERNAME}/.cargo/git
6055

61-
RUN rustup component add rustfmt && rm -rf /home/${USERNAME}/.cargo/registry/* && rm -rf /home/${USERNAME}/.cargo/git/*
56+
# Devcontainer resources
57+
COPY post_create_command.py ${MULTIVERSX}/devcontainer-resources/
6258

63-
# This command will be executed once the devcontainer is created
64-
COPY "post_create_command.py" "${MULTIVERSX}/devcontainer-resources/"
59+
CMD ["bash"]

src/smart-contracts-rust/devcontainer-template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "smart-contracts-rust",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"name": "MultiversX: Smart Contracts Development (Rust)",
55
"description": "Develop smart contracts for MultiversX. Includes Rust, mxpy, VSCode extensions etc.",
66
"documentationURL": "https://github.com/multiversx/mx-template-devcontainers/blob/main/src/smart-contracts-rust",

0 commit comments

Comments
 (0)