-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
95 lines (79 loc) · 3.11 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
ARG QUICKSTART_IMAGE_REF=stellar/quickstart:soroban-dev
ARG SOROBAN_CLI_IMAGE_REF=stellar/system-test-soroban-cli:dev
FROM golang:1.21 as go
RUN ["mkdir", "-p", "/test"]
RUN ["mkdir", "-p", "/test/bin"]
WORKDIR /test
ADD go.mod go.sum ./
RUN go mod download
ADD e2e.go ./
ADD features ./features
# build each feature folder with go test module.
# compiles each feature to a binary to be executed,
# and copies the .feature file with it for runtime.
RUN go test -c -o ./bin/dapp_develop_test.bin ./features/dapp_develop/...
ADD features/dapp_develop/dapp_develop.feature ./bin
# copy over a dapp develop test specific file, used for expect/tty usage
ADD features/dapp_develop/soroban_config.exp ./bin
FROM $SOROBAN_CLI_IMAGE_REF as soroban-cli
FROM $QUICKSTART_IMAGE_REF as base
ARG RUST_TOOLCHAIN_VERSION
ARG NODE_VERSION
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y build-essential expect git && apt-get clean
# Install Rust
RUN ["mkdir", "-p", "/rust"]
ENV CARGO_HOME=/rust/.cargo
ENV RUSTUP_HOME=/rust/.rust
ENV RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION
ENV PATH="/usr/local/go/bin:$CARGO_HOME/bin:${PATH}"
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN_VERSION"
# Use a non-root user
ARG USERNAME=tester
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
RUN ["mkdir", "-p", "/home/tester"]
USER tester
WORKDIR /home/tester
RUN mkdir -p ~/.ssh
RUN chmod 700 ~/.ssh
RUN echo "HOST *" > ~/.ssh/config
RUN echo "StrictHostKeyChecking no" >> ~/.ssh/config
# Install Node.js
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
ENV NVM_DIR=/home/tester/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/home/tester/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN npm install -g ts-node yarn
# Install js-stellar-sdk
ARG JS_STELLAR_SDK_NPM_VERSION
ADD package.json /home/tester/
ADD js-stellar-sdk /home/tester/js-stellar-sdk
RUN sudo chown -R tester:tester /home/tester
RUN yarn cache clean && yarn install --network-concurrency 1
RUN if echo "$JS_STELLAR_SDK_NPM_VERSION" | grep -q '.*file:.*'; then \
cd /home/tester/js-stellar-sdk; \
yarn cache clean; \
yarn install --network-concurrency 1; \
cd /home/tester; \
yarn add ${JS_STELLAR_SDK_NPM_VERSION} --network-concurrency 1; \
else \
yarn add "@stellar/stellar-sdk@${JS_STELLAR_SDK_NPM_VERSION}" --network-concurrency 1; \
fi
ADD *.ts /home/tester/bin/
RUN ["sudo", "chmod", "+x", "/home/tester/bin/invoke.ts"]
FROM base as build
# Tests expect to be run as root so they can launch stuff
USER root
ADD start /home/tester
COPY --from=soroban-cli /usr/local/cargo/bin/soroban $CARGO_HOME/bin/
COPY --from=go /test/bin/ /home/tester/bin
ENTRYPOINT ["/home/tester/start"]