1+ # --- Build Stage ---
2+ FROM node:22-slim@sha256:048ed02c5fd52e86fda6fbd2f6a76cf0d4492fd6c6fee9e2c463ed5108da0e34 AS builder
3+
4+ LABEL stage=builder
5+
6+ # Install required tools
7+ RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y \
8+ bash \
9+ curl \
10+ build-essential \
11+ && rm -rf /var/lib/apt/lists/*
12+
13+ # Create a working user
14+ RUN useradd -ms /bin/bash apprunner
15+
16+ # Define working directories
17+ RUN mkdir -p /juno && chown apprunner:apprunner /juno
18+
19+ # Use a user instead of using root
20+ USER apprunner
21+
22+ # Environment variables where files are downloaded and executed
23+ ENV TARGET_DIR=/juno/target
24+ RUN echo "export TARGET_DIR=${TARGET_DIR}" >> /home/apprunner/.bashrc
25+
26+ # Environment variables for using the Juno source repo
27+ ENV JUNO_MAIN_DIR=${TARGET_DIR}/juno-main
28+ RUN echo "export JUNO_MAIN_DIR=${JUNO_MAIN_DIR}" >> /home/apprunner/.bashrc
29+
30+ # Copy list of resources to download
31+ COPY --chown=apprunner:apprunner ./docker/download ./docker/download
32+
33+ # Download required artifacts and sources
34+ RUN ./docker/download/init
35+
36+ # Install Rust and Cargo in apprunner home
37+ ENV RUSTUP_HOME=/home/apprunner/.rustup \
38+ CARGO_HOME=/home/apprunner/.cargo \
39+ PATH=/home/apprunner/.cargo/bin:$PATH
40+
41+ # Copy list of scripts to run setup
42+ COPY --chown=apprunner:apprunner ./kit/setup ./kit/setup
43+
44+ # Install tools for building WASM with the action
45+ RUN ./kit/setup/bootstrap
46+
47+ # --- Runtime Stage ---
48+ FROM node:22-slim@sha256:048ed02c5fd52e86fda6fbd2f6a76cf0d4492fd6c6fee9e2c463ed5108da0e34
49+
50+ LABEL repository="https://github.com/junobuild/juno-action"
51+ LABEL homepage="https://juno.build"
52+ LABEL maintainer="David Dal Busco <david.dalbusco@outlook.com>"
53+
54+ LABEL com.github.actions.name="GitHub Action for Juno"
55+ LABEL com.github.actions.description="Enable arbitrary actions with the Juno CLI."
56+ LABEL com.github.actions.icon="package"
57+ LABEL com.github.actions.color="purple"
58+
59+ ENV TZ=UTC
60+
61+ # Install required tools
62+ RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y \
63+ build-essential \
64+ git \
65+ ca-certificates \
66+ && rm -rf /var/lib/apt/lists/*
67+
68+ # Install Juno's CLI
69+ RUN npm i -g @junobuild/cli@next
70+
71+ # Install pnpm which is not part of the default image
72+ RUN npm i -g pnpm@10.12.1
73+
74+ # Create and use a user instead of using root
75+ RUN useradd -ms /bin/bash apprunner
76+ USER apprunner
77+
78+ # Copy Cargo binaries
79+ COPY --from=builder --chown=apprunner:apprunner /home/apprunner/.cargo/bin /home/apprunner/.cargo/bin
80+
81+ # Copy Rust toolchain (includes rustc)
82+ COPY --from=builder --chown=apprunner:apprunner /home/apprunner/.rustup /home/apprunner/.rustup
83+
84+ # Define paths
85+ ENV CARGO_HOME=/home/apprunner/.cargo \
86+ RUSTUP_HOME=/home/apprunner/.rustup \
87+ PATH=/home/apprunner/.cargo/bin:$PATH
88+
89+ # Resolves cargo build error:
90+ # network failure seems to have happened
91+ # if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
92+ # https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
93+ RUN mkdir -p /home/apprunner/.cargo && \
94+ echo '[net]\ngit-fetch-with-cli = true' > /home/apprunner/.cargo/config.toml
95+
96+ # Copy docs and entrypoint
97+ COPY --chown=apprunner:apprunner LICENSE README.md /
98+ COPY --chown=apprunner:apprunner "entrypoint.sh" "/entrypoint.sh"
99+
100+ ENTRYPOINT ["/entrypoint.sh"]
101+ CMD ["--help"]
0 commit comments