Skip to content

Commit

Permalink
feat: Test docker container publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
AshtonStephens committed Oct 23, 2024
1 parent 634e9af commit ca0ef21
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
45 changes: 45 additions & 0 deletions .github/actions/dockerfiles/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM rust:1.81-slim-bookworm as builder

# Install dependencies.
RUN apt-get update
RUN apt-get install -y \
libclang-dev \
git \
pkg-config \
libssl-dev \
make \
protobuf-compiler \
npm \
default-jre
RUN npm install -g pnpm@9
RUN npm install -g @openapitools/openapi-generator-cli

WORKDIR /code/sbtc
COPY . .
RUN make install && make build

# Create Docker image to run the emily server.
FROM debian:bookworm-slim AS emily-server
WORKDIR /code
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /code/sbtc/target/debug/emily-server /usr/local/bin/emily-server
# Server configuration.
ENV HOST=0.0.0.0
ENV PORT=3030
# AWS configuration.
ENV AWS_ACCESS_KEY_ID=xxxxxxxxxxxx
ENV AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxx
ENV AWS_REGION=us-west-2
ENV DYNAMODB_ENDPOINT=http://dynamodb:8000
ENTRYPOINT ["/bin/sh", "-c", "/usr/local/bin/emily-server --host $HOST --port $PORT --dynamodb-endpoint $DYNAMODB_ENDPOINT"]

# Create Docker image to run the signer.
FROM debian:bookworm-slim AS signer
COPY --from=build /code/sbtc/target/debug/sbtc-signer /usr/local/bin/sbtc-signer
ENTRYPOINT ["/usr/local/bin/signer --config /signer-config.toml --migrate-db"]

# Create Docker image to run the blocklist client.
FROM debian:bookworm-slim AS blocklist-client
COPY --from=build /code/sbtc/target/debug/blocklist-client /usr/local/bin/blocklist-client
# TODO(TBD): Fix the blocklist client so it has a configurable config location.
ENTRYPOINT ["/usr/local/bin/blocklist-client"]
20 changes: 14 additions & 6 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ on:
required: true
type: string
description: "Version tag for docker images"
workflow_dispatch:
push:
branches:
- 693-chore-docker-container-publishing

## Define which docker arch to build for
env:
docker_platforms: "linux/arm64, linux/arm/v7, linux/amd64, linux/amd64/v3"
docker_platforms: "linux/arm64, linux/arm/v7, linux/amd64, linux/amd64/v3, linux/arm64/v8"
docker-org: blockstack

concurrency:
Expand All @@ -37,8 +41,11 @@ jobs:
max-parallel: 2
matrix:
dist:
- alpine
- debian
docker_target:
- signer
- emily-server
- blocklist-client
steps:
## Setup Docker for the builds
- name: Docker setup
Expand All @@ -65,9 +72,9 @@ jobs:
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 #v5.5.1
with:
## tag images with current repo name `stacks-core` as well as legacy `stacks-blockchain`
# ${{env.docker-org}}/${{ github.event.repository.name }}/${{ matrix.docker_target }}
images: |
${{env.docker-org}}/${{ github.event.repository.name }}
${{env.docker-org}}/stacks-blockchain
${{env.docker-org}}/sbtc/${{ matrix.docker_target }}
tags: |
type=raw,value=latest,enable=${{ inputs.tag != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'debian' }}
type=raw,value=${{ inputs.tag }}-${{ matrix.dist }},enable=${{ inputs.tag != '' && matrix.dist == 'debian'}}
Expand All @@ -77,14 +84,15 @@ jobs:
type=raw,value=${{ inputs.tag }}-${{ matrix.dist }},enable=${{ inputs.tag != '' && matrix.dist == 'alpine' }}
## Build docker image for release
- name: Build and Push ( ${{matrix.dist}} )
- name: Build and Push ( ${{matrix.dist}} ${{matrix.docker_target}} )
id: docker_build
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
file: ./.github/actions/dockerfiles/Dockerfile.${{ matrix.dist }}-binary
file: ./.github/actions/dockerfiles/Dockerfile.${{ matrix.dist }}
platforms: ${{ env.docker_platforms }}
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
target: ${{ matrix.docker_target }}
build-args: |
TAG=${{ inputs.tag }}
REPO=${{ github.repository_owner }}/${{ github.event.repository.name }}
Expand Down

0 comments on commit ca0ef21

Please sign in to comment.