Skip to content

Commit

Permalink
feat(machine-download): docker image to download machines from IPFS
Browse files Browse the repository at this point in the history
  • Loading branch information
tuler committed Oct 4, 2023
1 parent 00e7b6b commit 74b072e
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/machine-download.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: machine-download
on:
workflow_call:
pull_request:
paths:
- .github/workflows/machine-download.yaml
- packages/machine-download/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
id-token: write
actions: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get package tag/version
id: package-version
if: ${{ github.event_name == 'push' }}
run: |
jq -r '"PACKAGE_VERSION=\(.version)"' packages/machine-download/package.json >> "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
docker.io/cartesi/machine-download,enable=${{ github.event_name != 'pull_request' }}
ghcr.io/cartesi/machine-download
tags: |
type=raw,value=${{ steps.package-version.outputs.PACKAGE_VERSION }},enable=${{ github.event_name == 'push' }}
type=ref,event=pr
labels: |
org.opencontainers.image.title=Cartesi Machine Download
org.opencontainers.image.description=Cartesi Machine Download from IPFS
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- uses: depot/setup-action@v1
- name: Build and push
uses: depot/bake-action@v1
with:
project: ${{ vars.DEPOT_PROJECT }}
workdir: packages/machine-download
files: |
./docker-bake.hcl
./docker-bake.platforms.hcl
${{ steps.meta.outputs.bake-file }}
push: true
5 changes: 5 additions & 0 deletions packages/machine-download/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM golang:1.20-bookworm as builder
RUN go install github.com/ipfs/ipget@latest

FROM debian:bookworm-20230725
COPY --from=builder /go/bin/ipget /usr/local/bin/
13 changes: 13 additions & 0 deletions packages/machine-download/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Cartesi Machine Download

This Docker image provides an utility to download Cartesi Machines stored in IFPS using the [CAR](https://ipld.io/specs/transport/car/carv1/) format, and extracting to a local folder.

## Usage

The following command will download the Cartesi Machine with the given hash and extract it to the given folder:

```shell
docker run -t cartesi/machine-download:devel bafybeibdpcfqtcqhgjzmo5wzi3kraxdu6f4wm2hzna4tj2enkepzvldjtq /tmp
```

Obviously, the output directory can be in a volume mapped to outside the docker container.
6 changes: 6 additions & 0 deletions packages/machine-download/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target "docker-metadata-action" {}
target "docker-platforms" {}

target "default" {
inherits = ["docker-metadata-action", "docker-platforms"]
}
3 changes: 3 additions & 0 deletions packages/machine-download/docker-bake.override.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target "default" {
tags = ["cartesi/machine-download:devel"]
}
6 changes: 6 additions & 0 deletions packages/machine-download/docker-bake.platforms.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target "docker-platforms" {
platforms = [
"linux/amd64",
"linux/arm64"
]
}
8 changes: 8 additions & 0 deletions packages/machine-download/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@cartesi/machine-download",
"private": true,
"version": "0.1.0",
"scripts": {
"build": "docker buildx bake"
}
}

0 comments on commit 74b072e

Please sign in to comment.