Skip to content

Commit 4e6fcc3

Browse files
committed
docker: Add Dockerfile for developing ROFL on macOS
1 parent 8444b42 commit 4e6fcc3

File tree

4 files changed

+140
-13
lines changed

4 files changed

+140
-13
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: rofl-dev-image
3+
4+
on:
5+
push:
6+
# XXX: ideally on main branches we would build the image only if there are changes in the
7+
# 'docker/' directory (as we do in pull_requests). However, this doesn't work when pushing a new
8+
# 'stable/*' branch - the build on a new branch does not trigger unless there are changes
9+
# compared to main on the filtered path.
10+
# If this is ever fixed, or per branch filters are possible, bring back the path filter to only
11+
# build the image when there are changes within 'docker/' directory.
12+
branches:
13+
- main
14+
- stable/*
15+
# Or when a pull request event occurs for a pull request against one of the matched branches and at least
16+
# one modified file matches the configured paths.
17+
#
18+
# NOTE: We use this to be able to easily test Docker image changes.
19+
pull_request:
20+
branches:
21+
- main
22+
- stable/*
23+
paths:
24+
- docker/rofl-dev/**
25+
# Or every day at 04:00 UTC (for the default/main branch).
26+
schedule:
27+
- cron: "0 4 * * *"
28+
29+
# Cancel in-progress jobs on same branch.
30+
concurrency:
31+
group: ${{ github.workflow }}-${{ github.ref }}
32+
cancel-in-progress: true
33+
34+
jobs:
35+
36+
build-rofl-dev:
37+
# NOTE: This name appears in GitHub's Checks API.
38+
name: build-rofl-dev
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
with:
44+
# Check out pull request's HEAD commit instead of the merge commit.
45+
ref: ${{ github.event.pull_request.head.sha }}
46+
47+
- name: Determine tag name
48+
id: determine-tag
49+
uses: ./.github/actions/determine-tag
50+
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v3
53+
54+
- name: Login to ghcr.io
55+
uses: docker/login-action@v3
56+
with:
57+
registry: ghcr.io
58+
username: ${{ github.actor }}
59+
password: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: "Rebuild oasisprotocol/rofl-dev:${{ steps.determine-tag.outputs.tag }}"
62+
uses: docker/build-push-action@v5
63+
with:
64+
context: docker/rofl-dev
65+
file: docker/rofl-dev/Dockerfile
66+
tags: ghcr.io/oasisprotocol/rofl-dev:${{ steps.determine-tag.outputs.tag }}
67+
pull: true
68+
push: true
69+
labels: |
70+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
71+
org.opencontainers.image.created=${{ steps.determine-tag.outputs.created }}
72+
org.opencontainers.image.revision=${{ github.sha }}
73+
74+
- name: Prune old ghcr.io/oasisprotocol/rofl-dev images
75+
uses: vlaurin/action-ghcr-prune@v0.6.0
76+
with:
77+
token: ${{ secrets.GITHUB_TOKEN }}
78+
organization: oasisprotocol
79+
container: rofl-dev
80+
keep-younger-than: 7 # days
81+
keep-last: 2
82+
prune-untagged: true
83+
prune-tags-regexes: ^pr-

docker/rofl-dev/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM ghcr.io/oasisprotocol/oasis-core-dev:stable-24.3.x AS oasis-core-dev
2+
3+
ARG OASIS_CLI_VERSION=0.10.3
4+
5+
RUN curl -L -o /tmp/cli.tar.gz "https://github.com/oasisprotocol/cli/releases/download/v${OASIS_CLI_VERSION}/oasis_cli_${OASIS_CLI_VERSION}_linux_amd64.tar.gz" && \
6+
tar -C /usr/bin -xf /tmp/cli.tar.gz --strip-components 1 "oasis_cli_${OASIS_CLI_VERSION}_linux_amd64/oasis" && \
7+
rm /tmp/cli.tar.gz
8+
9+
VOLUME /src
10+
11+
WORKDIR /src

docs/rofl/app.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import Tabs from '@theme/Tabs';
2+
import TabItem from '@theme/TabItem';
3+
14
# Application
25

36
This chapter will show you how to quickly create, build and test a minimal
@@ -131,11 +134,23 @@ The simplest way to test and debug your ROFL is with a local stack.
131134
}
132135
```
133136

134-
2. Compile ROFL in the _unsafe_ mode:
135-
136-
```shell
137-
oasis rofl build sgx --mode unsafe
138-
```
137+
2. Compile ROFL in the _unsafe_ mode. If you're using the `rofl-dev`
138+
docker image (e.g. because you're developing on macOS), you can run the
139+
container, build the app, and stop the container in just a single
140+
command.
141+
142+
<Tabs>
143+
<TabItem value="local" label="Local">
144+
```shell
145+
oasis rofl build sgx --mode unsafe
146+
```
147+
</TabItem>
148+
<TabItem value="rofl-dev" label="Container">
149+
```shell
150+
docker run --platform linux/amd64 --volume ./rofl-oracle:/src -it ghcr.io/oasisprotocol/rofl-dev oasis rofl build sgx --mode unsafe
151+
```
152+
</TabItem>
153+
</Tabs>
139154

140155
3. Spin up the Sapphire Localnet docker container and mount your `rofl-oracle`
141156
folder to `/rofls` inside the docker image:

docs/rofl/prerequisites.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ If you already have everything set up, feel free to skip to the [next chapter].
1212

1313
[next chapter]: app.md
1414

15+
:::info
16+
17+
Docker images are available to help you set up a development
18+
environment. If you don't want to install everything locally (or **in
19+
particular if you use macOS** as your development system), you can use
20+
the `ghcr.io/oasisprotocol/rofl-dev` image, which contains all the tools
21+
needed to compile a ROFL app.
22+
23+
To use it, bind the directory with your app source to the container's
24+
`/src` directory with a command like the following, then continue with
25+
the next section of this guide:
26+
27+
```bash
28+
docker run --platform linux/amd64 --volume ./rofl-oracle:/src -it ghcr.io/oasisprotocol/rofl-dev
29+
```
30+
31+
Note that on macOS you **must** use the `--platform linux/amd64`
32+
parameter, no matter which processor your computer has.
33+
34+
:::
35+
1536
## Environment Setup
1637

1738
The following is a list of prerequisites required to start developing using the
@@ -77,20 +98,18 @@ nightly-2022-08-22-x86_64-unknown-linux-gnu (overridden by '/code/rust-toolchain
7798
rustc 1.65.0-nightly (c0941dfb5 2022-08-21)
7899
```
79100

80-
For testing ROFL binaries on Sapphire Localnet, the binaries should be compiled
81-
for [MUSL C standard library]. You will need to add the following target to your
82-
rust environment:
101+
Make sure you have the correct target for rust to compile for:
83102

84103
```shell
85-
rustup target add x86_64-unknown-linux-musl
104+
rustup target add x86_64-unknown-linux-gnu
86105
```
87106

88-
Additionally, you will need the MUSL wrapper for gcc, the multilib package and
89-
clang for compiling the `mbedtls-sys-auto` dependency. On Ubuntu/Debian systems,
107+
In addition, you will need gcc's multilib support package and clang for
108+
compiling the `mbedtls-sys-auto` dependency. On Ubuntu/Debian systems,
90109
you can install those by running:
91110

92111
```shell
93-
sudo apt install musl-tools gcc-multilib clang
112+
sudo apt install gcc-multilib clang
94113
```
95114

96115
<!-- markdownlint-disable line-length -->
@@ -100,7 +119,6 @@ sudo apt install musl-tools gcc-multilib clang
100119
[Rust]: https://www.rust-lang.org/
101120
[`rust-toolchain.toml`]: https://github.com/oasisprotocol/oasis-sdk/tree/main/rust-toolchain.toml
102121
[rust-toolchain-precedence]: https://github.com/rust-lang/rustup/blob/master/README.md#override-precedence
103-
[MUSL C standard library]: https://musl.libc.org/
104122
<!-- markdownlint-enable line-length -->
105123

106124
## SGXS Utilities

0 commit comments

Comments
 (0)