Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb1ca37b

Browse files
committed
ci: docker build
1 parent9fea07f commitb1ca37b

File tree

6 files changed

+139
-83
lines changed

6 files changed

+139
-83
lines changed

‎.github/workflows/CI.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
matrix:
2121
include:
2222
-os:macos-latest
23-
target:x86_64-osx
23+
target:x86_64-apple-darwin
2424
-os:ubuntu-latest
2525
target:x86_64-unknown-linux-musl
2626
coverage:true
@@ -30,6 +30,8 @@ jobs:
3030
force_lf:true
3131
-os:ubuntu-latest
3232
target:armv7-unknown-linux-musleabihf
33+
-os:ubuntu-latest
34+
target:aarch64-unknown-linux-gnu
3335
steps:
3436
-if:${{ matrix.force_lf }}
3537
run:|
@@ -82,7 +84,7 @@ jobs:
8284
files:lcov.info
8385
fail_ci_if_error:true
8486

85-
-name:Test with latest nextest release
87+
-name:Test
8688
if:${{ ! matrix.coverage }}
8789
uses:actions-rs/cargo@v1
8890
with:
Lines changed: 97 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,110 @@
1-
name:Docker latest
1+
name:Publish latest
22

33
on:
44
push:
55
branches:
6-
-"feat/docker-img"
6+
-feat/docker-img
7+
8+
env:
9+
CARGO_TERM_COLOR:always
710

811
jobs:
12+
build:
13+
name:Build cog ${{ matrix.os }}-${{ matrix.target }}
14+
runs-on:${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
include:
18+
-os:macos-latest
19+
target:x86_64-apple-darwin
20+
-os:ubuntu-latest
21+
target:x86_64-unknown-linux-musl
22+
-os:windows-latest
23+
target:x86_64-pc-windows-msvc
24+
windows:true
25+
-os:ubuntu-latest
26+
target:armv7-unknown-linux-musleabihf
27+
-os:ubuntu-latest
28+
target:aarch64-unknown-linux-gnu
29+
30+
steps:
31+
-uses:actions/checkout@v4
32+
33+
-uses:Swatinem/rust-cache@v2
34+
with:
35+
cache-all-crates:"true"
36+
key:"${{ matrix.os }}-${{ matrix.target }}"
37+
38+
-uses:actions-rs/toolchain@v1
39+
with:
40+
toolchain:stable
41+
target:${{ matrix.target }}
42+
43+
-if:${{ matrix.windows }}
44+
uses:actions-rs/cargo@v1
45+
with:
46+
command:build
47+
args:--target ${{ matrix.target }} --release --locked
48+
49+
-if:${{ ! matrix.windows }}
50+
uses:actions-rs/cargo@v1
51+
with:
52+
use-cross:true
53+
command:build
54+
args:--target ${{ matrix.target }} --release --locked
55+
56+
-if:${{ ! matrix.windows }}
57+
uses:actions/upload-artifact@v3
58+
with:
59+
name:${{ matrix.target }}
60+
path:target/${{ matrix.target }}/release/cog
61+
62+
-if:${{ matrix.windows }}
63+
uses:actions/upload-artifact@v3
64+
with:
65+
name:${{ matrix.target }}
66+
path:target/${{ matrix.target }}/release/cog.exe
67+
968
docker:
10-
name:Building docker image for ${{ matrix.os }}
69+
needs:[ build ]
70+
name:Docker publish cog:lastest
1171
runs-on:ubuntu-latest
12-
1372
steps:
14-
-name:Install docker buildx
15-
id:buildx
16-
uses:crazy-max/ghaction-docker-buildx@v1
73+
-uses:actions/checkout@v4
74+
75+
-name:Set up Docker Buildx
76+
uses:docker/setup-buildx-action@v1
77+
78+
-name:Login to GitHub Container Registry
79+
uses:docker/login-action@v3
80+
with:
81+
registry:ghcr.io
82+
username:${{ github.actor }}
83+
password:${{ secrets.GITHUB_TOKEN }}
84+
85+
-uses:actions/download-artifact@v3
1786
with:
18-
version:latest
87+
path:~/artifacts
1988

20-
-name:Checkout sources
21-
uses:actions/checkout@v3
89+
-name:Copy artifacts to build dir
90+
run:|
91+
mkdir -p target/x86_64-unknown-linux-musl/release/
92+
mkdir -p target/armv7-unknown-linux-musleabihf/release/
93+
mkdir -p target/aarch64-unknown-linux-gnu/release/
94+
95+
cp -r /home/runner/artifacts/x86_64-unknown-linux-musl target/x86_64-unknown-linux-musl/release/cog
96+
cp -r /home/runner/artifacts/armv7-unknown-linux-musleabihf target/armv7-unknown-linux-musleabihf/release/cog
97+
cp -r /home/runner/artifacts/aarch64-unknown-linux-gnu target/aarch64-unknown-linux-gnu/release/cog
98+
99+
chmod +x -R target/x86_64-unknown-linux-musl/release
100+
chmod +x -R target/armv7-unknown-linux-musleabihf/release
101+
chmod +x -R target/aarch64-unknown-linux-gnu/release
102+
working-directory:./
22103

23-
-name:Docker build
104+
-name:Update multi-arch container latest
24105
run:|
25-
docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64/v8 \
26-
-f docker/Dockerfile . \
27-
-t cocogitto/cocogitto:latest
106+
docker buildx build \
107+
--push --platform linux/amd64,linux/arm/v7,linux/arm64/v8 \
108+
-f docker/Dockerfile \
109+
-t ghcr.io/cocogitto/cog:latest .
110+

‎ci/action.sh‎

Lines changed: 0 additions & 48 deletions
This file was deleted.

‎ci/aur_bump.sh‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎docker/Dockerfile‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
FROM rust:1.73.0-slim-buster as builder
2-
RUN apt update && apt install -y git
1+
# Note that the following build needs binaries to be precompiled for the target
2+
# architectures. Use the `build-all` just recipies to build for all targets.
3+
FROM alpine as arm-builder
4+
COPY ./target/armv7-unknown-linux-musleabihf/release/cog /cog
35

4-
WORKDIR /build
5-
COPY .. .
6-
# Get the docker image architecture instead of the default host architecure from rustc
7-
RUN echo"$(rustc -vV | sed -n 's|host: ||p')" > rust_target
8-
RUN cargo build --target $(cat rust_target) --release --locked
9-
RUN mv /build/target/$(cat rust_target)/release/cog /
6+
FROM alpine as amd64-builder
7+
COPY ./target/x86_64-unknown-linux-musl/release/cog /cog
108

11-
FROM debian:buster-slim
9+
FROM alpine as arm64-builder
10+
COPY ./target/aarch64-unknown-linux-gnu/release/cog /cog
1211

13-
RUN apt update && apt install -y git
12+
FROM ${TARGETARCH}-builder AS builder
13+
14+
FROM alpine
15+
RUN apk add --no-cache git
1416

1517
# See https://git-scm.com/docs/git-config#Documentation/git-config.txt-safedirectory
1618
RUN echo'[safe]\n\tdirectory = *' > /etc/gitconfig
1719

18-
COPY --from=builder /cog /usr/local/bin/cog
20+
COPY --from=builder /cog /usr/bin/cog
1921
COPY docker/entrypoint.sh .
2022

2123
WORKDIR /app

‎justfile‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
clean-targets:
2+
rm -rd target/release
3+
rm target/.rustc_info.json
4+
5+
test:
6+
cargo install cargo-nextest
7+
cargo nextest run
8+
9+
build-x86:
10+
cross build --target x86_64-unknown-linux-musl --release
11+
justclean-targets
12+
13+
build-arm-v7:
14+
cross build --target armv7-unknown-linux-musleabihf --release
15+
justclean-targets
16+
17+
build-aarch64:
18+
cross build --target aarch64-unknown-linux-gnu --release
19+
justclean-targets
20+
21+
build-all:build-x86build-arm-v7build-aarch64
22+
23+
docker-build:build-all
24+
docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64/v8 . -t cocogitto/cog:latest -f docker/Dockerfile
25+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp