Skip to content

Commit

Permalink
Build devcontainer dojo version from commit hash
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed May 14, 2024
1 parent f648e87 commit 5c97156
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
12 changes: 8 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ] ; then \
fi

ARG DOJO_VERSION=stable
ARG BUILD_TYPE=default
RUN curl -L https://install.dojoengine.org | bash
RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash
ENV PATH=${PATH}:/root/.dojo/bin
RUN if [ "$DOJO_VERSION" = "stable" ]; then \
echo "Installing latest stable version of Dojo"; \
dojoup; \
else \
RUN if [ "$BUILD_TYPE" = "release" ]; then \
echo "Installing Dojo version $DOJO_VERSION"; \
dojoup -v $DOJO_VERSION; \
elif [ "$BUILD_TYPE" = "push" ]; then \
echo "Installing Dojo at commit $DOJO_VERSION"; \
dojoup -c $DOJO_VERSION; \
else \
echo "Installing latest stable version of Dojo"; \
dojoup; \
fi

RUN chown -R root:root /usr/local/cargo
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- ".github/workflows/devcontainer.yml"
- "!.devcontainer/devcontainer.json"
release:
types: [published, prereleased]
types: [published]

jobs:
build-and-push:
Expand Down Expand Up @@ -69,7 +69,8 @@ jobs:
tags: ghcr.io/${{ github.repository }}-dev:latest,ghcr.io/${{ github.repository }}-dev:${{ env.DOCKER_TAG }}
build-args: |
VARIANT=bookworm
DOJO_VERSION=${{ github.event_name == 'release' && github.event.release.tag_name || 'stable' }}
BUILD_TYPE=${{ github.event_name }}
DOJO_VERSION=${{ github.event.release.tag_name }}
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-dev:latest

Expand Down
4 changes: 3 additions & 1 deletion dojoup/dojoup
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ main() {
done

if [ -n "$DOJOUP_BRANCH" ] || [ -n "$DOJOUP_PR" ] || [ -n "$DOJOUP_COMMIT" ] || [ -n "$DOJOUP_LOCAL_REPO" ] || [ -n "$DOJOUP_REPO" ]; then
err "Rust is required for building from source. Please install Rust from https://www.rust-lang.org/tools/install."
if ! command -v rustc &> /dev/null; then
err "Rust is required for building from source. Please install Rust from https://www.rust-lang.org/tools/install."
fi
fi

if [ -n "$DOJOUP_PR" ]; then
Expand Down

0 comments on commit 5c97156

Please sign in to comment.