Skip to content

Commit f2d6167

Browse files
committed
feat: add xtask dockerfile
1 parent 375bdaa commit f2d6167

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Docker build and push xtask cli tool
2+
3+
on:
4+
push:
5+
branches:
6+
- feat/xtask-docker-image
7+
- main
8+
- dev
9+
paths:
10+
- 'xtask/**'
11+
- '.github/workflows/build-docker-xtask.yml'
12+
- 'docker/xtask.dockerfile'
13+
14+
jobs:
15+
docker:
16+
permissions:
17+
contents: read
18+
packages: write
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Docker meta
24+
id: meta
25+
uses: docker/metadata-action@v5
26+
with:
27+
images: ghcr.io/${{ github.repository_owner }}/torus-xtask
28+
tags: |
29+
type=sha,prefix=,enable=true
30+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Build and push
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: .
46+
push: true
47+
file: ./docker/xtask.dockerfile
48+
tags: ${{ steps.meta.outputs.tags }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max

docker/xtask.dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM rust:1.76-slim-bullseye as builder
2+
3+
WORKDIR /usr/src/app
4+
5+
RUN apt-get update && apt install -y --no-install-recommends \
6+
ca-certificates \
7+
curl \
8+
build-essential \
9+
protobuf-compiler \
10+
libclang-dev \
11+
git \
12+
pkg-config \
13+
libssl-dev
14+
15+
COPY . .
16+
17+
RUN cargo build --release --bin xtask
18+
19+
FROM debian:bullseye-slim
20+
21+
RUN apt-get update && apt install -y --no-install-recommends \
22+
ca-certificates \
23+
curl \
24+
build-essential \
25+
protobuf-compiler \
26+
libclang-dev \
27+
git \
28+
pkg-config \
29+
libssl-dev
30+
31+
COPY --from=builder /usr/src/app/target/release/xtask /usr/local/bin/
32+
33+
ENTRYPOINT ["xtask"]

0 commit comments

Comments
 (0)