Skip to content

Commit f348761

Browse files
committed
build docker image
1 parent dd6ecc4 commit f348761

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

.github/workflows/docker.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish Docker image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
push_to_registry:
10+
name: Docker
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out the repo
14+
uses: actions/checkout@v3
15+
with:
16+
submodules: true
17+
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v1
20+
21+
- name: Set up Docker Buildx
22+
id: buildx
23+
uses: docker/setup-buildx-action@v1
24+
25+
- name: Log in to GitHub Container Registry
26+
uses: docker/login-action@v2
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@v3
35+
with:
36+
images: ghcr.io/${{ github.repository }}
37+
38+
- name: Build and push Docker image
39+
uses: docker/build-push-action@v2
40+
with:
41+
context: .
42+
platforms: linux/amd64
43+
builder: ${{ steps.buildx.outputs.name }}
44+
push: ${{ github.event_name != 'pull_request' }}
45+
tags: |
46+
ghcr.io/${{ github.repository }}:latest
47+
${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max # mode=maxを有効にすると、中間ステージまで含めてキャッシュできる

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM debian:buster-slim AS build-dev
2+
3+
WORKDIR /app/src
4+
COPY --link . .
5+
6+
RUN apt-get update && \
7+
apt-get install -y gcc g++ cmake
8+
9+
ENV CC=/usr/bin/gcc \
10+
CXX=/usr/bin/g++
11+
12+
RUN mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Werror" .. && make example-file
13+
14+
FROM debian:buster-slim AS stage
15+
16+
COPY --from=build-dev /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
17+
COPY --from=build-dev /app/src/build/example/file/example-file /app/file
18+
ENTRYPOINT ["/app/file"]

0 commit comments

Comments
 (0)