Skip to content

Commit

Permalink
feat(docker): push image to dockerhub when pushing to main
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed Feb 22, 2022
1 parent f76b3d0 commit 332778a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 14 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/docker-emerald-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: docker-emerald-dev

on:
push:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
# We need history to determine emerald-web3-gateway version from git tag.
fetch-depth: 0

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

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

- name: Compute version
# Version emerald-dev image by date and git revision.
run: |
echo "VERSION=$(date +%Y-%m-%d-git$(git rev-parse --short HEAD))" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v2
with:
build-args: |
VERSION=${{ env.VERSION }}
context: .
file: docker/emerald-dev/Dockerfile
tags: |
oasisprotocol/emerald-dev:latest
oasisprotocol/emerald-dev:latest-${{ env.VERSION }}
push: true
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ release-build:
@goreleaser release --rm-dist

docker:
@docker build -t emerald-dev -f docker/emerald-dev/Dockerfile .
@docker build -t oasisprotocol/emerald-dev:local --build-arg VERSION=local -f docker/emerald-dev/Dockerfile .

# List of targets that are not actual files.
.PHONY: \
Expand Down
7 changes: 4 additions & 3 deletions docker/emerald-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ RUN cd emerald-web3-gateway && make build

FROM ubuntu:20.04

ENV VERSION=22.1
ENV OASIS_CORE_VERSION=21.3.9
ENV EMERALD_PARATIME_VERSION=6.2.0

ENV ETHEREUM_MNEMONIC="tray ripple elevator ramp insect butter top mouse old cinnamon panther chief"

ENV OASIS_NODE=/oasis-node
ENV OASIS_NET_RUNNER=/oasis-net-runner
ENV OASIS_NODE_DATADIR=/serverdir/node
Expand All @@ -19,6 +16,7 @@ ENV EMERALD_WEB3_GATEWAY=/emerald-web3-gateway
ENV EMERALD_WEB3_GATEWAY_CONFIG_FILE=/emerald-dev.yml
ENV OASIS_DEPOSIT=/oasis-deposit

ARG VERSION
ARG DEBIAN_FRONTEND=noninteractive

# emerald-web3-gateway binary, config, spinup-* scripts and staking_genesis.json.
Expand All @@ -40,6 +38,9 @@ RUN mkdir -p "$(dirname ${EMERALD_PARATIME})"
ADD "https://github.com/oasisprotocol/emerald-paratime/releases/download/v${EMERALD_PARATIME_VERSION}/emerald-paratime" "${EMERALD_PARATIME}"
RUN chmod a+x "${EMERALD_PARATIME}"

# Write VERSION information.
RUN echo "${VERSION}" > /VERSION

# Install Postgresql and other tools packaged by Ubuntu.
RUN apt update -qq \
&& apt dist-upgrade -qq -y \
Expand Down
25 changes: 19 additions & 6 deletions docker/emerald-dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,34 @@ set up your local development environment for dApps running on Emerald:
- emerald-web3-gateway
- oasis-deposit helper to fund your ethereum wallet

To build the docker image, go to your emerald-web3-gateway root folder
and run:
## Prebuilt images

Oasis provides prebuilt `emerald-dev` docker images. To run the `latest` version
based on the `main` branch of `emerald-web3-gateway` repository, run

```sh
docker run -it -p8545:8545 -p8546:8546 oasisprotocol/emerald-dev
```

## Build image locally

To build the docker image, go to your `emerald-web3-gateway` repository root
folder and run:

```sh
make docker
```

To run the Emerald development environment locally run:
To run the compiled image type:

```sh
docker run -it -p8545:8545 -p8546:8546 emerald-dev
docker run -it -p8545:8545 -p8546:8546 oasisprotocol/emerald-dev:local
```

You can now connect with your hardhat, truffle or metamask to
http://localhost:8545 or ws://localhost:8546
## Usage

Once the `emerald-dev` image is up and running, you can connect your hardhat,
truffle or metamask to http://localhost:8545 or ws://localhost:8546.

By default, a random mnemonic will be generated and the first 5 accounts will
be funded 100 ROSE. Flags `-amount`, `-to`, `-n` can be added to specify an
Expand Down
8 changes: 4 additions & 4 deletions docker/emerald-dev/start-emerald-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# starts the emerald web3 gateway on top of it, and deposits to a test account on Emerald.
# Mandatory ENV Variables:
# - all ENV variables required by spinup-oasis-stack.sh
# - VERSION: emerald-dev image version
# - OASIS_CORE_VERSION: version of oasis-node
# - EMERALD_WEB3_GATEWAY: path to emerald-web3-gateway binary
# - EMERALD_WEB3_GATEWAY_CONFIG_FILE: path to emerald-web3-gateway config file
# - OASIS_DEPOSIT: path to oasis-deposit binary

EMERALD_WEB3_GATEWAY_VERSION=$(${EMERALD_WEB3_GATEWAY} -v | head -n1 | cut -d " " -f 3)
echo "emerald-dev v${VERSION} (oasis-core: v${OASIS_CORE_VERSION}, emerald-paratime: v${EMERALD_PARATIME_VERSION}, emerald-web3-gateway: ${EMERALD_WEB3_GATEWAY_VERSION})"
EMERALD_WEB3_GATEWAY_VERSION=$(${EMERALD_WEB3_GATEWAY} -v | head -n1 | cut -d " " -f 3 | sed -r 's/^v//')
OASIS_CORE_VERSION=$(${OASIS_NODE} -v | head -n1 | cut -d " " -f 3 | sed -r 's/^v//')
VERSION=$(cat /VERSION)
echo "emerald-dev ${VERSION} (oasis-core: ${OASIS_CORE_VERSION}, emerald-paratime: ${EMERALD_PARATIME_VERSION}, emerald-web3-gateway: ${EMERALD_WEB3_GATEWAY_VERSION})"
echo

OASIS_NODE_SOCKET=${OASIS_NODE_DATADIR}/net-runner/network/client-0/internal.sock
Expand Down

0 comments on commit 332778a

Please sign in to comment.