Skip to content

Commit 9ce1b85

Browse files
authored
Merge pull request #63 from aminya/docker [skip ci]
2 parents 25cb863 + e982b85 commit 9ce1b85

15 files changed

+113
-51
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "eslint-config-atomic",
3-
"ignorePatterns": ["dist/", "node_modules/"]
3+
"ignorePatterns": ["dist/", "node_modules/", "dev/cpp_vcpkg_project"]
44
}

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,6 @@ jobs:
127127
- name: Build
128128
id: docker_build
129129
run: |
130-
docker build -f ./building/docker/${{ matrix.container }} -t setup_cpp .
130+
docker build -f ./dev/docker/${{ matrix.container }} -t setup_cpp .
131131
env:
132132
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "dev/cpp_vcpkg_project"]
2+
path = dev/cpp_vcpkg_project
3+
url = https://github.com/aminya/cpp_vcpkg_project

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ dist
66
stats.html
77
src/python/setup-python/
88
src/msvc/msvc-dev-cmd/
9+
dev/cpp_vcpkg_project

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ jobs:
179179
Here is an example for using setup_cpp to make a builder image that has the Cpp tools you need.
180180

181181
```dockerfile
182-
FROM ubuntu:devel
182+
#### Base Image
183+
FROM ubuntu:devel AS base
183184

184185
# add setup_cpp
185186
WORKDIR "/"
@@ -189,20 +190,35 @@ RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.
189190
RUN chmod +x ./setup_cpp_linux
190191

191192
# install llvm, cmake, ninja, and ccache
192-
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true
193-
194-
# activate cpp environment variables
195-
RUN source ~/.cpprc
196-
197-
ENTRYPOINT [ "/bin/sh" ]
193+
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true
194+
195+
CMD source ~/.cpprc
196+
ENTRYPOINT [ "/bin/bash" ]
197+
198+
#### Building
199+
FROM base AS builder
200+
ADD ./dev/cpp_vcpkg_project /home/app
201+
WORKDIR /home/app
202+
RUN bash -c 'source ~/.cpprc \
203+
&& make build'
204+
205+
### Running environment
206+
# use a distroless image or ubuntu:devel if you wish
207+
FROM gcr.io/distroless/cc
208+
# copy the built binaries and their runtime dependencies
209+
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
210+
WORKDIR /home/app/
211+
ENTRYPOINT ["./my_exe"]
198212
```
199213

200-
See [this folder](https://github.com/aminya/setup-cpp/tree/master/building/docker), for some dockerfile examples.
214+
See [this folder](https://github.com/aminya/setup-cpp/tree/master/dev/docker), for some dockerfile examples.
201215

202216
If you want to build the ones included, then run:
203217

204218
```ps1
205-
docker build -f ./building/docker/ubuntu.dockerfile -t setup_cpp .
219+
git clone --recurse-submodules https://github.com/aminya/setup-cpp
220+
cd ./setup-cpp
221+
docker build -f ./dev/docker/ubuntu.dockerfile -t setup_cpp .
206222
```
207223

208224
Where you should use the path to the dockerfile after `-f`.
@@ -230,7 +246,7 @@ jobs:
230246
- name: Build
231247
id: docker_build
232248
run: |
233-
docker build -f ./building/docker/debian.dockerfile -t setup_cpp .
249+
docker build -f ./dev/docker/debian.dockerfile -t setup_cpp .
234250
env:
235251
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
236252
```

building/docker/ubuntu.dockerfile

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

building/docker/ubuntu_node.dockerfile

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

cspell.config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ignorePaths:
77
- pnpm-lock.yaml
88
- .git/
99
- dist/
10+
- dev/cpp_vcpkg_project
1011
words:
1112
- aarch
1213
- aminya

dev/cpp_vcpkg_project

Submodule cpp_vcpkg_project added at f4fe216

dev/docker/ubuntu.dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#### Base Image
2+
FROM ubuntu:devel AS base
3+
4+
# add setup_cpp
5+
WORKDIR "/"
6+
RUN apt-get update -qq
7+
RUN apt-get install -y --no-install-recommends wget
8+
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.13.1/setup_cpp_linux"
9+
RUN chmod +x ./setup_cpp_linux
10+
11+
# install llvm, cmake, ninja, and ccache
12+
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true
13+
14+
CMD source ~/.cpprc
15+
ENTRYPOINT [ "/bin/bash" ]
16+
17+
#### Building
18+
FROM base AS builder
19+
ADD ./dev/cpp_vcpkg_project /home/app
20+
WORKDIR /home/app
21+
RUN bash -c 'source ~/.cpprc \
22+
&& make build'
23+
24+
### Running environment
25+
# use a distroless image or ubuntu:devel if you wish
26+
FROM gcr.io/distroless/cc
27+
# copy the built binaries and their runtime dependencies
28+
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
29+
WORKDIR /home/app/
30+
ENTRYPOINT ["./my_exe"]

0 commit comments

Comments
 (0)