Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cross-build Dockerfile and DockerHub publish action #310

Merged
merged 13 commits into from
Sep 5, 2023
67 changes: 67 additions & 0 deletions .github/workflows/docker_crossbuild_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Cross-Compile Docker Build and Push

on:
reqlez marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
types:
- opened
- synchronize
- closed

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- platform: 'linux/amd64'
ccarch: 'x86_64'
- platform: 'linux/arm64'
ccarch: 'aarch64'

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Generate Docker metadata
id: metadata
uses: docker/metadata-action@v3
with:
images: greenden/oracle-core
tags: |
type=ref,event=tag
- name: Build images
uses: docker/build-push-action@v3
with:
context: .
platforms: ${{ matrix.platform }}
tags: ${{ steps.metadata.outputs.tags }}
build-args: |
TARGETPLATFORM=${{ matrix.platform }}
CCARCH=${{ matrix.ccarch }}
push: false
load: true

push:
needs: build
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
reqlez marked this conversation as resolved.
Show resolved Hide resolved
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Combine and Push to DockerHub
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
tags: greenden/oracle-core:${{ github.ref_name }}, greenden/oracle-core:latest
push: true

34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Valid CCARCH options: aarch64 or the default x86_64
ARG CCARCH="x86_64"

FROM --platform=$BUILDPLATFORM messense/rust-musl-cross:${CCARCH}-musl AS builder
WORKDIR /home/rust/src
COPY . .

RUN rm rust-toolchain

RUN cargo build --release

RUN apt-get update && apt-get --only-upgrade install -y ca-certificates
RUN update-ca-certificates

RUN adduser \
--disabled-password \
--gecos "oracle-core" \
--home "/data" \
--shell "/bin/sh" \
--no-create-home \
--uid "9010" \
oracle-core

FROM --platform=$TARGETPLATFORM busybox:stable-musl AS final
ARG CCARCH="x86_64"
greenhat marked this conversation as resolved.
Show resolved Hide resolved
COPY --from=builder /home/rust/src/target/${CCARCH}-unknown-linux-musl/release/oracle-core /usr/local/bin/oracle-core
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd

EXPOSE 9010 9011

USER oracle-core

CMD ["oracle-core", "--oracle-config-file", "/data/oracle_config.yaml", "--pool-config-file", "/data/pool_config.yaml", "-d", "/data", "run", "--enable-rest-api"]
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@ The current oracle core is built to run the protocol specified in the [EIP-0023

## Getting started

### Docker Image

AMD64 and ARM64 images are available from [Docker Hub Repo](https://hub.docker.com/r/ergoplatform/oracle-core)

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 ).

An example docker run command:

``` console
docker run -d \
-v /path/on/host:/data \
-p 9010:9010 \
-p 9011:9011 \
-e ORACLE_NODE_API_KEY=CHANGE_ME_KEY \
ergoplatform/oracle-core:latest
```

To enter container shell for debugging or pool modifications:

``` console
docker exec -it -u oracle-core <container id> /bin/sh
```

### Download

Get the latest release binary from [Releases](https://github.com/ergoplatform/oracle-core/releases)
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.66.1
1.71.1
Loading