Skip to content

Commit f59102a

Browse files
authored
Merge pull request #310 from reqlez/oracle-core-docker
Add cross-build Dockerfile and DockerHub publish action
2 parents c75a643 + aa68b9d commit f59102a

File tree

4 files changed

+125
-1
lines changed

4 files changed

+125
-1
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Cross-Compile Docker Build and Push
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- closed
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
include:
16+
- platform: 'linux/amd64'
17+
ccarch: 'x86_64'
18+
- platform: 'linux/arm64'
19+
ccarch: 'aarch64'
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v1
27+
28+
- name: Generate Docker metadata
29+
id: metadata
30+
uses: docker/metadata-action@v3
31+
with:
32+
images: greenden/oracle-core
33+
tags: |
34+
type=ref,event=tag
35+
- name: Build images
36+
uses: docker/build-push-action@v3
37+
with:
38+
context: .
39+
platforms: ${{ matrix.platform }}
40+
tags: ${{ steps.metadata.outputs.tags }}
41+
build-args: |
42+
TARGETPLATFORM=${{ matrix.platform }}
43+
CCARCH=${{ matrix.ccarch }}
44+
push: false
45+
load: true
46+
47+
push:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v1
53+
54+
- name: Login to DockerHub
55+
uses: docker/login-action@v2
56+
with:
57+
username: ${{ secrets.DOCKERHUB_USERNAME }}
58+
password: ${{ secrets.DOCKERHUB_TOKEN }}
59+
60+
- name: Combine and Push to DockerHub
61+
uses: docker/build-push-action@v3
62+
with:
63+
context: .
64+
platforms: linux/amd64,linux/arm64
65+
tags: greenden/oracle-core:${{ github.ref_name }}, greenden/oracle-core:latest
66+
push: true
67+

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Valid CCARCH options: aarch64 or the default x86_64
2+
ARG CCARCH="x86_64"
3+
4+
FROM --platform=$BUILDPLATFORM messense/rust-musl-cross:${CCARCH}-musl AS builder
5+
WORKDIR /home/rust/src
6+
COPY . .
7+
8+
RUN rm rust-toolchain
9+
10+
RUN cargo build --release
11+
12+
RUN apt-get update && apt-get --only-upgrade install -y ca-certificates
13+
RUN update-ca-certificates
14+
15+
RUN adduser \
16+
--disabled-password \
17+
--gecos "oracle-core" \
18+
--home "/data" \
19+
--shell "/bin/sh" \
20+
--no-create-home \
21+
--uid "9010" \
22+
oracle-core
23+
24+
FROM --platform=$TARGETPLATFORM busybox:stable-musl AS final
25+
ARG CCARCH="x86_64"
26+
COPY --from=builder /home/rust/src/target/${CCARCH}-unknown-linux-musl/release/oracle-core /usr/local/bin/oracle-core
27+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
28+
COPY --from=builder /etc/passwd /etc/passwd
29+
30+
EXPOSE 9010 9011
31+
32+
USER oracle-core
33+
34+
CMD ["oracle-core", "--oracle-config-file", "/data/oracle_config.yaml", "--pool-config-file", "/data/pool_config.yaml", "-d", "/data", "run", "--enable-rest-api"]

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@ The current oracle core is built to run the protocol specified in the [EIP-0023
1616

1717
## Getting started
1818

19+
### Docker Image
20+
21+
AMD64 and ARM64 images are available from [Docker Hub Repo](https://hub.docker.com/r/ergoplatform/oracle-core)
22+
23+
The container runs under oracle-core user ( 9010 uid ), if using bind mount for container's /data folder ( where config files and other data lives ), set the container's uid for the host's folder ownership ( ex: chown -R 9010:9010 oracle_data ).
24+
25+
An example docker run command:
26+
27+
``` console
28+
docker run -d \
29+
-v /path/on/host:/data \
30+
-p 9010:9010 \
31+
-p 9011:9011 \
32+
-e ORACLE_NODE_API_KEY=CHANGE_ME_KEY \
33+
ergoplatform/oracle-core:latest
34+
```
35+
36+
To enter container shell for debugging or pool modifications:
37+
38+
``` console
39+
docker exec -it -u oracle-core <container id> /bin/sh
40+
```
41+
1942
### Download
2043

2144
Get the latest release binary from [Releases](https://github.com/ergoplatform/oracle-core/releases)

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.66.1
1+
1.71.1

0 commit comments

Comments
 (0)