Skip to content

Commit c5daf55

Browse files
feat: Dockerfile.full with cargo and required dependencies to build (#20)
* feat: add cargo and required dependencies to image * feat: stages to reduce size * feat: remove volume * docs: run locally with a dummy but valid token * docs: run * feat: copy full cargo and rustup * feat: use juno main * feat: certificate * feat: git * fix: run * feat: use next for now * feat: separate file * feat: for consistency with juno-docker * chore: build and test full in CI * chore: naming * chore: lint * docs: build full local
1 parent 2639988 commit c5daf55

8 files changed

Lines changed: 189 additions & 9 deletions

File tree

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
# include required files with an exception
44
!entrypoint.sh
55
!LICENSE
6-
!README.md
6+
!README.md
7+
!docker/**
8+
!kit/**

.github/workflows/build.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Docker Image
1+
name: Build Docker Images
22

33
on:
44
workflow_dispatch:
@@ -7,10 +7,13 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
dockerfile: [ Dockerfile, Dockerfile.full ]
1013
steps:
1114
# Action: https://github.com/actions/checkout/releases/tag/v4.2.2
1215
- name: Check out the repo
1316
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
1417

15-
- name: Build the Docker image
16-
run: docker build . --file Dockerfile
18+
- name: Build Docker image ${{ matrix.dockerfile }}
19+
run: docker build . --file ${{ matrix.dockerfile }}

.github/workflows/test-cli.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Juno CLI runs from Docker image
1+
name: Test Juno CLI runs from Docker images
22

33
on:
44
workflow_dispatch:
@@ -7,6 +7,9 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
dockerfile: [ Dockerfile, Dockerfile.full ]
1013
steps:
1114
# Action: https://github.com/actions/checkout/releases/tag/v4.2.2
1215
- name: Check out the repo
@@ -21,15 +24,15 @@ jobs:
2124
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
2225
with:
2326
context: .
24-
file: Dockerfile
27+
file: ${{ matrix.dockerfile }}
2528
load: true
26-
tags: juno-action:latest
29+
tags: juno-action:test-${{ matrix.dockerfile == 'Dockerfile.full' && 'full' || 'slim' }}
2730
cache-from: type=gha
2831
cache-to: type=gha,mode=max
2932

3033
- name: Test Juno CLI version
3134
run: |
32-
OUTPUT=$(docker run --rm -e JUNO_TOKEN="${{ secrets.JUNO_TOKEN }}" juno-action version --cli)
35+
OUTPUT=$(docker run --rm -e JUNO_TOKEN="${{ secrets.JUNO_TOKEN }}" juno-action:test-${{ matrix.dockerfile == 'Dockerfile.full' && 'full' || 'slim' }} version --cli)
3336
echo "$OUTPUT"
3437
if [[ "$OUTPUT" != *"v0.4.0"* ]]; then
3538
echo "❌ Expected version v0.4.0 not found in output"

Dockerfile.full

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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"]

HACKING.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ Here are a few useful Docker commands that can be used for local development.
66

77
```bash
88
docker build . --file Dockerfile -t juno-action --progress=plain --no-cache
9+
docker build . --file Dockerfile.full -t juno-action --progress=plain --no-cache --platform=linux/amd64
910
```
1011

11-
### Inspect size
12+
### Inspect Size
1213

1314
```bash
1415
docker images juno-action
@@ -22,6 +23,24 @@ docker pull node:22-slim
2223
docker inspect --format='{{index .RepoDigests 0}}' node:22-slim
2324
```
2425

26+
## Run Locally
27+
28+
`juno --version`:
29+
30+
```bash
31+
docker run --rm -e JUNO_TOKEN=eyJ0b2tlbiI6WyIzMDJhMzAwNTA2MDMyYjY1NzAwMzIxMDA0Y2E0NzhjNmEzMmVkZTgzMmU5OWY3ODBiNjM3ZWE4NDk4MzdhYTY1YTI5YTRlOWNmYmRkYjU1Njc1NGFlNjkwIiwiZjYwMGJhNzRiN2JmYjJiODIzY2VkMWYzYjkzMTY0YzE1NDM2MDBjOTZlZmZmODFhMmU0YmUxZTYxNTU5NGRkYyJdfQ== juno-action --version
32+
```
33+
34+
`juno dev build`:
35+
36+
```bash
37+
docker run --rm \
38+
-e JUNO_TOKEN=eyJ0b2tlbiI6WyIzMDJhMzAwNTA2MDMyYjY1NzAwMzIxMDA0Y2E0NzhjNmEzMmVkZTgzMmU5OWY3ODBiNjM3ZWE4NDk4MzdhYTY1YTI5YTRlOWNmYmRkYjU1Njc1NGFlNjkwIiwiZjYwMGJhNzRiN2JmYjJiODIzY2VkMWYzYjkzMTY0YzE1NDM2MDBjOTZlZmZmODFhMmU0YmUxZTYxNTU5NGRkYyJdfQ== \
39+
-v "$(pwd)":/project \
40+
-w /project \
41+
juno-action dev build
42+
```
43+
2544
### References
2645

2746
This project is inspired by [w9jds/firebase-action](https://github.com/w9jds/firebase-action)

docker/download/init

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
./docker/download/juno-source

docker/download/juno-source

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
DIR="$TARGET_DIR"
6+
7+
if [ ! -d "$DIR" ]; then
8+
mkdir "$DIR"
9+
fi
10+
11+
# Use a specific commit
12+
# COMMIT=9c42f96920a768afa5a2ea24c038b699c40491d5
13+
# SOURCE_FOLDER="juno-$COMMIT"
14+
# curl -L -o "$DIR/juno.tar.gz" https://github.com/junobuild/juno/archive/$COMMIT.tar.gz
15+
16+
# Use a release tag
17+
# TAG=v0.0.48
18+
# SOURCE_FOLDER="juno-${TAG#v}"
19+
# curl -L -o "$DIR/juno.tar.gz" https://github.com/junobuild/juno/archive/refs/tags/$TAG.tar.gz
20+
21+
# Use main
22+
BRANCH=main
23+
SOURCE_FOLDER="juno-$BRANCH"
24+
curl -L -o "$DIR/juno.tar.gz" https://github.com/junobuild/juno/archive/refs/heads/$BRANCH.tar.gz
25+
26+
tar -xf "$DIR/juno.tar.gz" -C "$DIR"
27+
28+
# Rename the extracted folder to juno-main if branch is not main
29+
# mv "$DIR/$SOURCE_FOLDER" "$JUNO_MAIN_DIR"
30+
31+
echo "juno source downloaded and extracted to $JUNO_MAIN_DIR."

kit/setup/bootstrap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
BOOTSTRAP_SCRIPT="/juno/target/juno-main/docker/bootstrap"
6+
7+
function bootstrap() {
8+
if [[ ! -f "$BOOTSTRAP_SCRIPT" ]]; then
9+
echo "Error: $BOOTSTRAP_SCRIPT not found!" >&2
10+
exit 1
11+
fi
12+
13+
exec "$BOOTSTRAP_SCRIPT"
14+
}
15+
16+
bootstrap

0 commit comments

Comments
 (0)