Skip to content

Commit ebd14f4

Browse files
authored
Merge pull request #237 from aminya/docker-publish
2 parents 2908244 + c8e2110 commit ebd14f4

31 files changed

+74
-164
lines changed

.github/workflows/CI.yml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Build
5656
run: |
5757
pnpm build
58-
pnpm build.docker_tests
58+
pnpm build.docker-ci
5959
6060
- name: Lint
6161
run: |
@@ -215,7 +215,7 @@ jobs:
215215
node ./dist/actions/setup-cpp.js --help
216216
217217
Docker:
218-
name: Test-${{ matrix.container }}
218+
name: Docker-${{ matrix.container.image }}
219219
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
220220
needs: [Build]
221221
runs-on: ${{ matrix.os }}
@@ -229,12 +229,12 @@ jobs:
229229
pnpm:
230230
- 8
231231
container:
232-
- "ubuntu.dockerfile"
233-
- "fedora.dockerfile"
234-
- "arch.dockerfile"
235-
- "ubuntu-mingw.dockerfile"
236-
# - "fedora-mingw.dockerfile"
237-
# - "arch-mingw.dockerfile"
232+
- { file: "ubuntu-llvm.dockerfile", image: "setup-cpp-ubuntu-llvm", tag: "22.04-0.37.0" }
233+
- { file: "fedora-llvm.dockerfile", image: "setup-cpp-fedora-llvm", tag: "40-0.37.0" }
234+
- { file: "arch-llvm.dockerfile", image: "setup-cpp-arch-llvm", tag: "base-0.37.0" }
235+
- { file: "ubuntu-mingw.dockerfile", image: "setup-cpp-ubuntu-mingw", tag: "22.04-0.37.0" }
236+
# - { file: "fedora-mingw.dockerfile", image: "setup-cpp-fedora-mingw", tag: "40-0.37.0" }
237+
# - { file: "arch-mingw.dockerfile", image: "setup-cpp-arch-mingw", tag: "base-0.37.0" }
238238
steps:
239239
- uses: actions/checkout@v4
240240
with:
@@ -245,10 +245,28 @@ jobs:
245245
with:
246246
name: dist
247247

248-
- name: Build
249-
id: docker_build
250-
run: |
251-
docker build -f ./dev/docker/__tests__/${{ matrix.container }} -t setup-cpp .
248+
- name: Login to Docker Hub
249+
uses: docker/login-action@v3
250+
if: ${{ github.event_name != 'pull_request' }}
251+
with:
252+
username: ${{ vars.DOCKERHUB_USERNAME }}
253+
password: ${{ secrets.DOCKERHUB_TOKEN }}
254+
255+
- name: Build and push
256+
uses: docker/build-push-action@v5
257+
with:
258+
context: .
259+
file: ./dev/docker/ci/${{ matrix.container.file }}
260+
push: ${{ github.event_name != 'pull_request' }}
261+
tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:${{ matrix.container.tag }},${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:latest
262+
263+
- name: Test
264+
uses: docker/build-push-action@v5
265+
with:
266+
context: .
267+
file: ./dev/docker/examples/${{ matrix.container.file }}
268+
push: false
269+
tags: ${{ vars.DOCKERHUB_USERNAME }}/test-${{ matrix.container.image }}:${{ matrix.container.tag }}
252270

253271
Release:
254272
if: startsWith(github.ref, 'refs/tags/')

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,15 @@ If you want to build the ones included, then run:
211211
```shell
212212
git clone --recurse-submodules https://github.com/aminya/setup-cpp
213213
cd ./setup-cpp
214-
docker build -f ./dev/docker/setup-cpp-ubuntu.dockerfile -t setup-cpp-ubuntu .
214+
docker build -f ./dev/docker/setup-cpp/setup-cpp-ubuntu.dockerfile -t setup-cpp-ubuntu-llvm:22.04-17 ./
215215
```
216216

217217
Where you should use the path to the dockerfile after `-f`.
218218

219219
After build, run the following to start an interactive shell in your container
220220

221221
```shell
222-
docker run -it setup-cpp
222+
docker run -it setup-cpp-ubuntu-llvm:22.04-17
223223
```
224224

225225
### Inside Docker inside GitHub Actions

dev/docker/__tests__/arch-mingw.dockerfile

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

dev/docker/__tests__/arch.dockerfile renamed to dev/docker/ci/arch-llvm.dockerfile

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,3 @@ RUN pacman -Syuu --noconfirm && \
2727
rm -rf /tmp/*
2828

2929
ENTRYPOINT ["/bin/bash"]
30-
31-
#### Building (example)
32-
FROM setup-cpp-arch AS builder
33-
34-
COPY ./dev/cpp_vcpkg_project /home/app
35-
WORKDIR /home/app
36-
RUN bash -c 'source ~/.cpprc \
37-
&& task build'
38-
39-
#### Running environment
40-
# use a fresh image as the runner
41-
FROM archlinux:base as runner
42-
43-
# copy the built binaries and their runtime dependencies
44-
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
45-
WORKDIR /home/app/
46-
ENTRYPOINT ["./my_exe"]
File renamed without changes.

dev/docker/ci/arch-mingw.dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## base image
2+
FROM archlinux:base as setup-cpp-arch-mingw
3+
4+
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
5+
6+
RUN pacman -Syuu --noconfirm && \
7+
pacman-db-upgrade && \
8+
# install nodejs
9+
pacman -S --noconfirm --needed nodejs npm && \
10+
11+
# install the compiler and tools
12+
node /usr/lib/setup-cpp/setup-cpp.js \
13+
--compiler mingw \
14+
--cmake true \
15+
--ninja true \
16+
--task true \
17+
--vcpkg true \
18+
--python true \
19+
--make true \
20+
--cppcheck true \
21+
--gcovr true \
22+
--doxygen true \
23+
--ccache true && \
24+
# arch cleanup
25+
pacman -Scc --noconfirm && \
26+
rm -rf /var/cache/pacman/pkg/* && \
27+
rm -rf /tmp/*
28+
29+
ENTRYPOINT ["/bin/bash"]
File renamed without changes.

dev/docker/__tests__/generate-docker-tests.mjs renamed to dev/docker/ci/docker-ci.mjs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
import { readFile, writeFile } from "fs/promises"
22

33
async function main() {
4-
const dockerFiles = ["ubuntu", "arch", "fedora", "ubuntu-mingw", "arch-mingw", "fedora-mingw"]
4+
const names = ["ubuntu-llvm", "arch-llvm", "fedora-llvm", "ubuntu-mingw", "arch-mingw", "fedora-mingw"]
55
await Promise.all(
6-
dockerFiles.map(async (dockerFile) => {
7-
const dockerFileContent = await readFile(`./dev/docker/setup-cpp-${dockerFile}.dockerfile`, "utf-8")
8-
const builderExample = await readFile(`./dev/docker/${dockerFile}.dockerfile`, "utf-8")
9-
6+
names.map(async (name) => {
7+
const dockerFileContent = await readFile(`./dev/docker/setup-cpp/setup-cpp-${name}.dockerfile`, "utf-8")
108
const modifiedDockerFile = dockerFileContent
119
// load the externally built setup-cpp
1210
.replace(/FROM (.*)/g, `FROM $1\n\nCOPY "./dist/legacy" "/usr/lib/setup-cpp/"`)
1311
.replace("setup-cpp ", "node /usr/lib/setup-cpp/setup-cpp.js ")
1412
// remove the npm install line
1513
.replace(/# install setup-cpp\n\s*npm install -g setup-cpp.*/, "")
1614

17-
// concat the two files
18-
const newDockerFileContent = `${modifiedDockerFile}\n${builderExample}`
19-
20-
// write the new file in dev/docker/__tests__
21-
await writeFile(`./dev/docker/__tests__/${dockerFile}.dockerfile`, newDockerFileContent)
15+
// write the new file in dev/docker/ci
16+
await writeFile(`./dev/docker/ci/${name}.dockerfile`, modifiedDockerFile)
2217
}),
2318
)
2419
}

dev/docker/__tests__/fedora.dockerfile renamed to dev/docker/ci/fedora-llvm.dockerfile

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,3 @@ RUN dnf -y install nodejs npm && \
2424
rm -rf /tmp/*
2525

2626
ENTRYPOINT ["/bin/bash"]
27-
28-
#### Building (example)
29-
FROM setup-cpp-fedora AS builder
30-
31-
COPY ./dev/cpp_vcpkg_project /home/app
32-
WORKDIR /home/app
33-
RUN bash -c 'source ~/.cpprc \
34-
&& task build'
35-
36-
#### Running environment
37-
# use a fresh image as the runner
38-
FROM fedora:40 as runner
39-
40-
# copy the built binaries and their runtime dependencies
41-
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
42-
WORKDIR /home/app/
43-
ENTRYPOINT ["./my_exe"]
File renamed without changes.

0 commit comments

Comments
 (0)