Skip to content

Commit

Permalink
docker flow
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Feb 8, 2023
1 parent 29a7186 commit 1d61be1
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: docker

on:
workflow_dispatch:
inputs:
branch:
description: Branch to build docker image (optional).
required: false
type: string

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch || github.ref }}
submodules: recursive
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: acala/${{ github.event.repository.name }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=sha
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
submodules: recursive
- name: Check format
run: cargo fmt --all -- --check
- name: Check clippy
Expand Down
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM rust:buster as builder
WORKDIR /app

COPY . .

RUN cargo build --release --verbose

# =============

FROM phusion/baseimage:focal-1.2.0
LABEL maintainer="[email protected]"

RUN useradd -m -u 1000 -U -s /bin/sh -d /app docker

WORKDIR /app

COPY --from=builder /app/target/release/subway /usr/local/bin
COPY ./config.yml /app/config.yml

# checks
RUN ldd /usr/local/bin/subway && \
/usr/local/bin/subway --version

# Shrinking
RUN rm -rf /usr/lib/python* && \
rm -rf /usr/sbin /usr/share/man

USER docker
EXPOSE 9944

ENTRYPOINT ["/usr/local/bin/subway"]

0 comments on commit 1d61be1

Please sign in to comment.