Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
# include required files with an exception
!entrypoint.sh
!LICENSE
!README.md
!README.md
!docker/**
!kit/**
9 changes: 6 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Docker Image
name: Build Docker Images

on:
workflow_dispatch:
Expand All @@ -7,10 +7,13 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dockerfile: [ Dockerfile, Dockerfile.full ]
steps:
# Action: https://github.com/actions/checkout/releases/tag/v4.2.2
- name: Check out the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Build the Docker image
run: docker build . --file Dockerfile
- name: Build Docker image ${{ matrix.dockerfile }}
run: docker build . --file ${{ matrix.dockerfile }}
11 changes: 7 additions & 4 deletions .github/workflows/test-cli.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Juno CLI runs from Docker image
name: Test Juno CLI runs from Docker images

on:
workflow_dispatch:
Expand All @@ -7,6 +7,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dockerfile: [ Dockerfile, Dockerfile.full ]
steps:
# Action: https://github.com/actions/checkout/releases/tag/v4.2.2
- name: Check out the repo
Expand All @@ -21,15 +24,15 @@ jobs:
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
with:
context: .
file: Dockerfile
file: ${{ matrix.dockerfile }}
load: true
tags: juno-action:latest
tags: juno-action:test-${{ matrix.dockerfile == 'Dockerfile.full' && 'full' || 'slim' }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test Juno CLI version
run: |
OUTPUT=$(docker run --rm -e JUNO_TOKEN="${{ secrets.JUNO_TOKEN }}" juno-action version --cli)
OUTPUT=$(docker run --rm -e JUNO_TOKEN="${{ secrets.JUNO_TOKEN }}" juno-action:test-${{ matrix.dockerfile == 'Dockerfile.full' && 'full' || 'slim' }} version --cli)
echo "$OUTPUT"
if [[ "$OUTPUT" != *"v0.4.0"* ]]; then
echo "❌ Expected version v0.4.0 not found in output"
Expand Down
101 changes: 101 additions & 0 deletions Dockerfile.full
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# --- Build Stage ---
FROM node:22-slim@sha256:048ed02c5fd52e86fda6fbd2f6a76cf0d4492fd6c6fee9e2c463ed5108da0e34 AS builder

LABEL stage=builder

# Install required tools
RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y \
bash \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Create a working user
RUN useradd -ms /bin/bash apprunner

# Define working directories
RUN mkdir -p /juno && chown apprunner:apprunner /juno

# Use a user instead of using root
USER apprunner

# Environment variables where files are downloaded and executed
ENV TARGET_DIR=/juno/target
RUN echo "export TARGET_DIR=${TARGET_DIR}" >> /home/apprunner/.bashrc

# Environment variables for using the Juno source repo
ENV JUNO_MAIN_DIR=${TARGET_DIR}/juno-main
RUN echo "export JUNO_MAIN_DIR=${JUNO_MAIN_DIR}" >> /home/apprunner/.bashrc

# Copy list of resources to download
COPY --chown=apprunner:apprunner ./docker/download ./docker/download

# Download required artifacts and sources
RUN ./docker/download/init

# Install Rust and Cargo in apprunner home
ENV RUSTUP_HOME=/home/apprunner/.rustup \
CARGO_HOME=/home/apprunner/.cargo \
PATH=/home/apprunner/.cargo/bin:$PATH

# Copy list of scripts to run setup
COPY --chown=apprunner:apprunner ./kit/setup ./kit/setup

# Install tools for building WASM with the action
RUN ./kit/setup/bootstrap

# --- Runtime Stage ---
FROM node:22-slim@sha256:048ed02c5fd52e86fda6fbd2f6a76cf0d4492fd6c6fee9e2c463ed5108da0e34

LABEL repository="https://github.com/junobuild/juno-action"
LABEL homepage="https://juno.build"
LABEL maintainer="David Dal Busco <david.dalbusco@outlook.com>"

LABEL com.github.actions.name="GitHub Action for Juno"
LABEL com.github.actions.description="Enable arbitrary actions with the Juno CLI."
LABEL com.github.actions.icon="package"
LABEL com.github.actions.color="purple"

ENV TZ=UTC

# Install required tools
RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y \
build-essential \
git \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Install Juno's CLI
RUN npm i -g @junobuild/cli@next

# Install pnpm which is not part of the default image
RUN npm i -g pnpm@10.12.1

# Create and use a user instead of using root
RUN useradd -ms /bin/bash apprunner
USER apprunner

# Copy Cargo binaries
COPY --from=builder --chown=apprunner:apprunner /home/apprunner/.cargo/bin /home/apprunner/.cargo/bin

# Copy Rust toolchain (includes rustc)
COPY --from=builder --chown=apprunner:apprunner /home/apprunner/.rustup /home/apprunner/.rustup

# Define paths
ENV CARGO_HOME=/home/apprunner/.cargo \
RUSTUP_HOME=/home/apprunner/.rustup \
PATH=/home/apprunner/.cargo/bin:$PATH

# Resolves cargo build error:
# network failure seems to have happened
# if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
# https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
RUN mkdir -p /home/apprunner/.cargo && \
echo '[net]\ngit-fetch-with-cli = true' > /home/apprunner/.cargo/config.toml

# Copy docs and entrypoint
COPY --chown=apprunner:apprunner LICENSE README.md /
COPY --chown=apprunner:apprunner "entrypoint.sh" "/entrypoint.sh"

ENTRYPOINT ["/entrypoint.sh"]
CMD ["--help"]
21 changes: 20 additions & 1 deletion HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ Here are a few useful Docker commands that can be used for local development.

```bash
docker build . --file Dockerfile -t juno-action --progress=plain --no-cache
docker build . --file Dockerfile.full -t juno-action --progress=plain --no-cache --platform=linux/amd64
```

### Inspect size
### Inspect Size

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

## Run Locally

`juno --version`:

```bash
docker run --rm -e JUNO_TOKEN=eyJ0b2tlbiI6WyIzMDJhMzAwNTA2MDMyYjY1NzAwMzIxMDA0Y2E0NzhjNmEzMmVkZTgzMmU5OWY3ODBiNjM3ZWE4NDk4MzdhYTY1YTI5YTRlOWNmYmRkYjU1Njc1NGFlNjkwIiwiZjYwMGJhNzRiN2JmYjJiODIzY2VkMWYzYjkzMTY0YzE1NDM2MDBjOTZlZmZmODFhMmU0YmUxZTYxNTU5NGRkYyJdfQ== juno-action --version
```

`juno dev build`:

```bash
docker run --rm \
-e JUNO_TOKEN=eyJ0b2tlbiI6WyIzMDJhMzAwNTA2MDMyYjY1NzAwMzIxMDA0Y2E0NzhjNmEzMmVkZTgzMmU5OWY3ODBiNjM3ZWE4NDk4MzdhYTY1YTI5YTRlOWNmYmRkYjU1Njc1NGFlNjkwIiwiZjYwMGJhNzRiN2JmYjJiODIzY2VkMWYzYjkzMTY0YzE1NDM2MDBjOTZlZmZmODFhMmU0YmUxZTYxNTU5NGRkYyJdfQ== \
-v "$(pwd)":/project \
-w /project \
juno-action dev build
```

### References

This project is inspired by [w9jds/firebase-action](https://github.com/w9jds/firebase-action)
5 changes: 5 additions & 0 deletions docker/download/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -euo pipefail

./docker/download/juno-source
31 changes: 31 additions & 0 deletions docker/download/juno-source
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -euo pipefail

DIR="$TARGET_DIR"

if [ ! -d "$DIR" ]; then
mkdir "$DIR"
fi

# Use a specific commit
# COMMIT=9c42f96920a768afa5a2ea24c038b699c40491d5
# SOURCE_FOLDER="juno-$COMMIT"
# curl -L -o "$DIR/juno.tar.gz" https://github.com/junobuild/juno/archive/$COMMIT.tar.gz

# Use a release tag
# TAG=v0.0.48
# SOURCE_FOLDER="juno-${TAG#v}"
# curl -L -o "$DIR/juno.tar.gz" https://github.com/junobuild/juno/archive/refs/tags/$TAG.tar.gz

# Use main
BRANCH=main
SOURCE_FOLDER="juno-$BRANCH"
curl -L -o "$DIR/juno.tar.gz" https://github.com/junobuild/juno/archive/refs/heads/$BRANCH.tar.gz

tar -xf "$DIR/juno.tar.gz" -C "$DIR"

# Rename the extracted folder to juno-main if branch is not main
# mv "$DIR/$SOURCE_FOLDER" "$JUNO_MAIN_DIR"

echo "juno source downloaded and extracted to $JUNO_MAIN_DIR."
16 changes: 16 additions & 0 deletions kit/setup/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euo pipefail

BOOTSTRAP_SCRIPT="/juno/target/juno-main/docker/bootstrap"

function bootstrap() {
if [[ ! -f "$BOOTSTRAP_SCRIPT" ]]; then
echo "Error: $BOOTSTRAP_SCRIPT not found!" >&2
exit 1
fi

exec "$BOOTSTRAP_SCRIPT"
}

bootstrap