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

chore: add Dockerfile and docker-build workflow #5

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docker

on:
workflow_dispatch:
push:
branches: ["develop"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these branches enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't mind, I suggest change the default branch to develop.

All tags will trigger image building too.
And, other branches could use the workflow_dispatch event.

Flouse marked this conversation as resolved.
Show resolved Hide resolved
tags:

jobs:
docker-build-push:
runs-on: ubuntu-22.04
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
context: git
images: ghcr.io/${{ github.repository }}
flavor: |
latest=auto
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmm'}}
type=sha,enable=true,prefix=sha-,format=short
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
provenance: false
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
build-args: |
RUST_RELEASE_MODE=release
CARGO_BUILD_FEATURES=default
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM rust:latest AS builder

WORKDIR /app
COPY . /app

RUN apt-get update && apt-get install --no-install-recommends -y clang
RUN cargo build --release

FROM ubuntu:latest

ARG DEBCONF_NOWARNINGS="yes"
ARG DEBIAN_FRONTEND noninteractive
ARG DEBCONF_NONINTERACTIVE_SEEN true

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
tini \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY --from=builder /app/target/release/ckb-bitcoin-spv-service /usr/local/bin/ckb-bitcoin-spv-service

RUN chmod a+x /usr/local/bin/ckb-bitcoin-spv-service

ENTRYPOINT [ "tini", "--"]
CMD ["ckb-bitcoin-spv-service", "--help"]