Skip to content

Commit 3527814

Browse files
authored
Rootless + updates (#44)
* Limit the number of tags we list - versions bumps - update GH workflows - add tests - fix justfile fix #30 fix #38 * Fix and add tests * Switch to Rust 1.60 * Fix ACL * Remove unrequired folder * Switch to a user install of Rust * Fix to allow properly detecting source type * Fix tests * Add container-structure-test to CI (failing on purpose in this commit) * Fixes and cleanup, remove rustc stable * Fix test * Prep to allow other profiles than `release` * Change version to 0.9.21 * Rust 1.61, Ubuntu 22 * Upgrade to Rust 1.62.0 * Add new image tag * Remove bridges * Bump versions * Cleanup
1 parent c61240a commit 3527814

25 files changed

+330
-174
lines changed

.github/workflows/manual-acala.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Manual Build - Acala
22

33
env:
4-
SUBWASM_VERSION: 0.17.0
4+
SUBWASM_VERSION: 0.18.0
55

66
on:
77
workflow_dispatch:
88
inputs:
99
srtool_tag:
1010
description: The SRTOOL tag to use
11-
default: 1.60.0
11+
default: 1.62.0
1212
required: false
1313
ref:
1414
description: The ref to be used for the repo

.github/workflows/manual-bridges.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.github/workflows/manual-cumulus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Manual Build - Cumulus
22

33
env:
4-
SUBWASM_VERSION: 0.17.0
4+
SUBWASM_VERSION: 0.18.0
55

66
on:
77
workflow_dispatch:
88
inputs:
99
srtool_tag:
1010
description: The SRTOOL tag to use
11-
default: 1.60.0
11+
default: 1.62.0
1212
required: false
1313
ref:
1414
description: The ref to be used for the repo

.github/workflows/manual-moonbeam.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Manual Build - Moonbeam
22

33
env:
4-
SUBWASM_VERSION: 0.17.0
4+
SUBWASM_VERSION: 0.18.0
55

66
on:
77
workflow_dispatch:
88
inputs:
99
srtool_tag:
1010
description: The SRTOOL tag to use
11-
default: 1.60.0
11+
default: 1.62.0
1212
required: false
1313
ref:
1414
description: The ref to be used for the repo

.github/workflows/manual-polkadot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Manual Build - Polkadot
22

33
env:
4-
SUBWASM_VERSION: 0.17.0
4+
SUBWASM_VERSION: 0.18.0
55

66
on:
77
workflow_dispatch:
88
inputs:
99
srtool_tag:
1010
description: The SRTOOL tag to use
11-
default: 1.60.0
11+
default: 1.62.0
1212
required: false
1313
ref:
1414
description: The ref to be used for the repo

.github/workflows/manual-shiden.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Manual Build - Shiden
22

33
env:
4-
SUBWASM_VERSION: 0.17.0
4+
SUBWASM_VERSION: 0.18.0
55

66
on:
77
workflow_dispatch:
88
inputs:
99
srtool_tag:
1010
description: The SRTOOL tag to use
11-
default: 1.60.0
11+
default: 1.62.0
1212
required: false
1313
ref:
1414
description: The ref to be used for the repo

.github/workflows/manual.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Manual Build
22

33
env:
4-
SUBWASM_VERSION: 0.17.0
4+
SUBWASM_VERSION: 0.18.0
55

66
on:
77
workflow_dispatch:
88
inputs:
99
srtool_tag:
1010
description: The SRTOOL tag to use
11-
default: 1.60.0
11+
default: 1.62.0
1212
required: false
1313
srtool_image:
1414
description: The SRTOOL image to use

.github/workflows/tests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,49 @@ jobs:
7676
echo $VERSION
7777
fi
7878
79+
container-structure-test:
80+
runs-on: ubuntu-latest
81+
needs: build
82+
continue-on-error: false
83+
steps:
84+
- uses: actions/checkout@v3
85+
with:
86+
ref: ${{ github.event.pull_request.head.sha }}
87+
88+
- name: Show files
89+
run: |
90+
ls -al
91+
92+
- name: Cache the image
93+
uses: actions/cache@v2
94+
with:
95+
key: srtool-docker-image-${{ github.sha }}
96+
path: |
97+
srtool.tar.gz
98+
99+
- name: Install tooling
100+
run: |
101+
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 && \
102+
chmod +x container-structure-test-linux-amd64 && \
103+
mkdir -p $HOME/bin && \
104+
export PATH=$PATH:$HOME/bin && \
105+
mv container-structure-test-linux-amd64 $HOME/bin/container-structure-test
106+
echo "Installed version:"
107+
container-structure-test version
108+
109+
- name: Load Docker image
110+
run: |
111+
docker load -i srtool.tar.gz
112+
docker images --digests
113+
114+
- name: Run the tests
115+
run: |
116+
export PATH=$PATH:$HOME/bin
117+
TESTS=$(find tests -type f | sed -e 's/^/ --config /g' | tr -d '\n')
118+
echo "Running tests:"
119+
find tests -type f
120+
container-structure-test test --image srtool --verbosity info ${TESTS}
121+
79122
polkadot:
80123
runs-on: ubuntu-latest
81124
needs: build
@@ -124,6 +167,19 @@ jobs:
124167
echo $INFO
125168
fi
126169
170+
- name: Run some debug
171+
env:
172+
PACKAGE: ${{ matrix.chain }}-runtime
173+
RUNTIME_DIR: runtime/${{ matrix.chain }}
174+
working-directory: polkadot
175+
run: |
176+
ls -al runtime || true
177+
ls -al runtime/${{ matrix.chain }} || true
178+
id -u runner || true
179+
id -g runner || true
180+
id -u docker || true
181+
docker info --format "{{ .ClientInfo.Context }}"
182+
127183
- name: Run srtool build for ${{ matrix.chain }}
128184
id: srtool_build
129185
env:

Dockerfile

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,69 @@
1-
FROM docker.io/library/ubuntu:20.04
1+
FROM docker.io/library/ubuntu:22.04
22

33
LABEL maintainer "[email protected]"
44
LABEL description="This image contains tools for Substrate blockchains runtimes."
55

6-
ARG RUSTC_VERSION="1.60.0"
6+
ARG RUSTC_VERSION="1.62.0"
77
ENV RUSTC_VERSION=$RUSTC_VERSION
88
ENV DOCKER_IMAGE="paritytech/srtool"
99
ENV PROFILE=release
1010
ENV PACKAGE=polkadot-runtime
11+
ENV BUILDER=builder
12+
ARG UID=1001
13+
ARG GID=1001
14+
15+
ENV SRTOOL_TEMPLATES=/srtool/templates
16+
17+
RUN groupadd -g $GID $BUILDER && \
18+
useradd --no-log-init -m -u $UID -s /bin/bash -d /home/$BUILDER -r -g $BUILDER $BUILDER
19+
RUN mkdir -p ${SRTOOL_TEMPLATES} && \
20+
mkdir /build && chown -R $BUILDER /build && \
21+
mkdir /out && chown -R $BUILDER /out
1122

12-
RUN mkdir -p /cargo-home /rustup-home /srtool/templates
1323
WORKDIR /tmp
14-
ENV RUSTUP_HOME="/rustup-home"
15-
ENV CARGO_HOME="/cargo-home"
1624
ENV DEBIAN_FRONTEND=noninteractive
1725

1826
# Tooling
19-
ARG SUBWASM_VERSION=0.17.0
27+
ARG SUBWASM_VERSION=0.18.0
2028
ARG TERA_CLI_VERSION=0.2.1
2129
ARG TOML_CLI_VERSION=0.2.1
2230

23-
# We first init as much as we can in the first layers
24-
COPY ./scripts/init.sh /srtool/
25-
COPY ./templates /srtool/templates/
31+
COPY ./templates ${SRTOOL_TEMPLATES}/
2632
RUN apt update && \
2733
apt upgrade -y && \
2834
apt install --no-install-recommends -y \
2935
cmake pkg-config libssl-dev make \
3036
git clang bsdmainutils ca-certificates curl && \
3137
curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 --output /usr/bin/jq && chmod a+x /usr/bin/jq && \
32-
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUSTC_VERSION -y && \
3338
rm -rf /var/lib/apt/lists/* /tmp/* && apt clean
3439

35-
ENV PATH="/srtool:/cargo-home/bin:$PATH"
36-
RUN export PATH=/cargo-home/bin:/rustup-home:$PATH && \
37-
git config --global --add safe.directory /build && \
38-
/srtool/init.sh && \
39-
curl -L https://github.com/chevdor/subwasm/releases/download/v${SUBWASM_VERSION}/subwasm_linux_amd64_v${SUBWASM_VERSION}.deb --output subwasm.deb && dpkg -i subwasm.deb && subwasm --version && \
40+
RUN curl -L https://github.com/chevdor/subwasm/releases/download/v${SUBWASM_VERSION}/subwasm_linux_amd64_v${SUBWASM_VERSION}.deb --output subwasm.deb && dpkg -i subwasm.deb && subwasm --version && \
4041
curl -L https://github.com/chevdor/tera-cli/releases/download/v${TERA_CLI_VERSION}/tera-cli_linux_amd64.deb --output tera_cli.deb && dpkg -i tera_cli.deb && tera --version && \
4142
curl -L https://github.com/chevdor/toml-cli/releases/download/v${TOML_CLI_VERSION}/toml_linux_amd64_v${TOML_CLI_VERSION}.deb --output toml.deb && dpkg -i toml.deb && toml --version && \
42-
mv -f /cargo-home/bin/* /bin && \
43-
touch /cargo-home/env && \
44-
mkdir /out && \
45-
rustup show && rustc -V
46-
47-
# We copy the .cargo/bin away for 2 reasons.
48-
# - easier with paths
49-
# - mostly because it allows using a volume for .cargo without 'missing' the cargo bin when mapping an empty folder
50-
51-
# RUN echo 'export PATH="/srtool/:$PATH"' >> $HOME/.bashrc
43+
rm -rf /tmp/*
5244

53-
# we copy those only at the end which makes testing of new scripts faster as the other layers are cached
5445
COPY ./scripts/* /srtool/
5546
COPY VERSION /srtool/
5647
COPY RUSTC_VERSION /srtool/
5748

58-
VOLUME [ "/build", "/cargo-home", "/out" ]
49+
USER $BUILDER
50+
ENV RUSTUP_HOME="/home/${BUILDER}/rustup"
51+
ENV CARGO_HOME="/home/${BUILDER}/cargo"
52+
ENV PATH="/srtool:$PATH"
53+
54+
RUN echo $SHELL && \
55+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
56+
. $CARGO_HOME/env && \
57+
rustup toolchain add stable ${RUSTC_VERSION} && \
58+
rustup target add wasm32-unknown-unknown --toolchain $RUSTC_VERSION && \
59+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME && \
60+
rustup show && rustc -V
61+
62+
RUN git config --global --add safe.directory /build && \
63+
/srtool/version && \
64+
echo 'PATH=".:$HOME/cargo/bin:$PATH"' >> $HOME/.bashrc
65+
66+
VOLUME [ "/build", "$CARGO_HOME", "/out" ]
5967
WORKDIR /srtool
6068

6169
CMD ["/srtool/build"]

0 commit comments

Comments
 (0)