Skip to content

Commit 8fd8335

Browse files
committed
added Docker container to run tests
1 parent 7422fef commit 8fd8335

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ProjectFolder/build

Dockerfile

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Development / Testing image for C++ template cmake project
1+
# Development / Testing image for C++ CMake template project
22

33
# base image used as the starting point for this image
44
FROM debian:latest
@@ -9,20 +9,14 @@ FROM debian:latest
99
RUN apt-get update \
1010
&& apt-get install -y \
1111
apt-utils \
12-
wget \
13-
curl \
1412
git \
15-
vim \
1613
build-essential \
1714
libtool autoconf pkg-config \
18-
ninja-build \
1915
clang \
2016
llvm \
2117
libc++-dev libc++abi-dev \
2218
cmake \
23-
# libboost1.74-dev \
2419
libboost-all-dev \
25-
# compiler cash
2620
ccache \
2721
&& apt-get clean && rm -rf /var/lib/apt/lists/*
2822

@@ -40,14 +34,17 @@ ARG TEST_VAR_DOCKERFILE=test
4034
COPY ProjectFolder /ProjectFolder
4135

4236
# Setting the working directory inside the project folder
43-
WORKDIR /ProjectFolder/
37+
WORKDIR /
4438

4539
# Running Cmake build script, all cmake files are generated
46-
RUN scripts/cmake_build.sh
40+
RUN ProjectFolder/scripts/cmake_build.sh
4741

4842
# Building the project using the build files generated by Cmake
49-
RUN scripts/make_debug.sh
43+
RUN ProjectFolder/scripts/make_debug.sh
5044

51-
# The command that is run by default by the container when "docker run ..."/"docker start ..." is used
52-
# CMD ["/bin/bash"]
53-
CMD ["./build/debug/bin/cpp-cmake-template"]
45+
WORKDIR /ProjectFolder/build/debug
46+
47+
# The command that is run by default when the container starts
48+
CMD ["ctest", "--output-on-failure"]
49+
# Run this to launch the project binary instead
50+
# CMD ["./ProjectFolder/build/debug/bin/cpp-cmake-template"]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Execute script:
2626

2727
```./ProjectFolder/scripts/run_tests.sh```<br>
2828
or execute task "run_tests" in VSCode.
29+
30+
To run tests in a Docker container:<br>
31+
```docker compose down --volumes --rmi all```<br>
32+
```docker compose up```
2933
<h2>Add a new file:</h2>
3034
- Create the new file in the desired folder.<br>
3135
- Add file.cpp in the CMakeLists.txt file (the one in the same folder as the file).<br>

docker-compose.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ version: "3.7"
22

33
services:
44
dev-container:
5-
volumes:
6-
- template-volume:/template-folder
75

86
build:
97
context: .
@@ -12,7 +10,7 @@ services:
1210
tty: true
1311

1412
environment:
15-
- TEST_VAR_COMPOSE=asd
13+
- TEST_VAR_COMPOSE=test
1614

1715
ports:
1816
- 8080:5555

0 commit comments

Comments
 (0)