Skip to content

Commit

Permalink
added Docker container to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mortinger91 committed Feb 20, 2023
1 parent 7422fef commit 8fd8335
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ProjectFolder/build
23 changes: 10 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Development / Testing image for C++ template cmake project
# Development / Testing image for C++ CMake template project

# base image used as the starting point for this image
FROM debian:latest
Expand All @@ -9,20 +9,14 @@ FROM debian:latest
RUN apt-get update \
&& apt-get install -y \
apt-utils \
wget \
curl \
git \
vim \
build-essential \
libtool autoconf pkg-config \
ninja-build \
clang \
llvm \
libc++-dev libc++abi-dev \
cmake \
# libboost1.74-dev \
libboost-all-dev \
# compiler cash
ccache \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

Expand All @@ -40,14 +34,17 @@ ARG TEST_VAR_DOCKERFILE=test
COPY ProjectFolder /ProjectFolder

# Setting the working directory inside the project folder
WORKDIR /ProjectFolder/
WORKDIR /

# Running Cmake build script, all cmake files are generated
RUN scripts/cmake_build.sh
RUN ProjectFolder/scripts/cmake_build.sh

# Building the project using the build files generated by Cmake
RUN scripts/make_debug.sh
RUN ProjectFolder/scripts/make_debug.sh

# The command that is run by default by the container when "docker run ..."/"docker start ..." is used
# CMD ["/bin/bash"]
CMD ["./build/debug/bin/cpp-cmake-template"]
WORKDIR /ProjectFolder/build/debug

# The command that is run by default when the container starts
CMD ["ctest", "--output-on-failure"]
# Run this to launch the project binary instead
# CMD ["./ProjectFolder/build/debug/bin/cpp-cmake-template"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Execute script:

```./ProjectFolder/scripts/run_tests.sh```<br>
or execute task "run_tests" in VSCode.

To run tests in a Docker container:<br>
```docker compose down --volumes --rmi all```<br>
```docker compose up```
<h2>Add a new file:</h2>
- Create the new file in the desired folder.<br>
- Add file.cpp in the CMakeLists.txt file (the one in the same folder as the file).<br>
Expand Down
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ version: "3.7"

services:
dev-container:
volumes:
- template-volume:/template-folder

build:
context: .
Expand All @@ -12,7 +10,7 @@ services:
tty: true

environment:
- TEST_VAR_COMPOSE=asd
- TEST_VAR_COMPOSE=test

ports:
- 8080:5555

0 comments on commit 8fd8335

Please sign in to comment.