Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Add services docker container (#788)
Browse files Browse the repository at this point in the history
Close #724
  • Loading branch information
sveitser authored Mar 21, 2022
1 parent 2013701 commit 8b4f5b1
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 9 deletions.
63 changes: 59 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,25 @@ jobs:
publish_dir: ./doc/mdbook/book/
cname: cape.docs.espressosys.com

- name: Build Wallet
run: nix-shell --run "cargo build -p cape_wallet --release"
- name: Build all executables
run: nix-shell --run "cargo build --release"

- uses: actions/upload-artifact@v2
with:
name: wallet-webserver
path: |
target/release/wallet-api
docker:
- uses: actions/upload-artifact@v2
with:
name: services-executables
path: |
target/release/address-book
target/release/eqs
target/release/faucet
target/release/minimal-relayer
docker-wallet:
runs-on: self-hosted
needs: build
steps:
Expand Down Expand Up @@ -124,7 +133,53 @@ jobs:
name: Build and Push Docker
with:
context: ./wallet-checkout/
file: ./Dockerfile
file: ./wallet.Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

docker-services:
runs-on: self-hosted
needs: build
steps:
- uses: actions/checkout@v2
name: Checkout Repository
with:
path: services-checkout

- uses: actions/download-artifact@v2
with:
name: services-executables
path: services-checkout/target/release/

- uses: docker/setup-buildx-action@v1
name: Setup Docker BuildKit (buildx)
with:
driver: docker

- uses: docker/login-action@v1
name: Login to Github Container Repo
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/metadata-action@v3
name: Generate Docker Metadata
id: meta
with:
images: ghcr.io/espressosystems/cape/services

- name: Generate base image
run: cd services-checkout && bin/build-docker-base

- uses: docker/build-push-action@v2
name: Build and Push Docker
with:
context: ./services-checkout/
file: ./services.Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,20 @@ To build the project run
The `--release` flag is recommended because without it many cryptographic
computations the project relies one become unbearably slow.

## Wallet Docker image
## Docker images

To build the wallet Docker container locally run
To build the wallet or services Docker images locally run

build-docker-wallet

inside a nix shell from the root directory of the repo. For the CI build see the
`docker` job in [.github/workflows/build.yml](.github/workflows/build.yml).
or

build-docker-services

inside a nix shell from the root directory of the repo.

For the CI build see the `docker-*` jobs in
[.github/workflows/build.yml](.github/workflows/build.yml).

# Development

Expand Down
5 changes: 5 additions & 0 deletions address_book/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ authors = ["Espresso Systems <[email protected]>"]
edition = "2018"
description = "Web server that maintains a persistent mapping from user addresses to user public keys"
license = "GPL-3.0-or-later"
default-run = "address-book"

[[bin]]
name = "address-book"
path = "src/main.rs"

[dependencies]
futures = "0.3.21"
Expand Down
4 changes: 4 additions & 0 deletions bin/build-docker-services
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e
build-docker-base
docker build -t cape/services -f ./services.Dockerfile .
2 changes: 1 addition & 1 deletion bin/build-docker-wallet
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -e
build-docker-base
docker build .
docker build -t cape/wallet -f ./wallet.Dockerfile .
24 changes: 24 additions & 0 deletions services.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM nix-base-docker

# EQS
# docker run --workdir /app/eqs -it cape/services /app/eqs/eqs
COPY target/release/eqs /app/eqs/eqs
RUN chmod +x /app/eqs/eqs
COPY eqs/api /app/eqs/api

# Minimal relayer
# docker run -it cape/services /app/relayer/minimal-relayer
COPY target/release/minimal-relayer /app/relayer/minimal-relayer
RUN chmod +x /app/relayer/minimal-relayer

# Faucet
# docker run -it cape/services /app/faucet/faucet
COPY target/release/faucet /app/faucet/faucet
RUN chmod +x /app/faucet/faucet

# Address book
# docker run -it cape/services /app/address-book/address-book
COPY target/release/address-book /app/address-book/address-book
RUN chmod +x /app/address-book/address-book

WORKDIR /app/
File renamed without changes.

0 comments on commit 8b4f5b1

Please sign in to comment.