Skip to content

Commit

Permalink
Port to cpp-container image
Browse files Browse the repository at this point in the history
  • Loading branch information
kbuffardi committed Mar 25, 2024
1 parent 46d6396 commit df32b2e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
34 changes: 19 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
FROM ubuntu:latest
LABEL title="C++ Analysis"
LABEL version=0.2
ENV CXXFLAGS=-std=c++17
LABEL title="CPP Container"
LABEL version=0.1
ENV GTEST_REPO=/googletest
ENV GTEST_DIR=${GTEST_REPO}/googletest
ENV WORKDIR=/usr/src
WORKDIR /usr/src

# Set Docker arguments
ARG DEBIAN_FRONTEND=noninteractive

# Install dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y -f \
dos2unix \
apt-get install -y \
build-essential \
g++ \
cmake \
git-all \
pmccabe \
cccc
dos2unix

# Get source and make sure it uses unix line feed (no carriage return)
COPY . ./
RUN dos2unix *
# Setup GoogleTest
RUN git clone --depth=1 https://github.com/google/googletest ${GTEST_REPO}
RUN mkdir ${GTEST_REPO}/build && cd ${GTEST_REPO}/build \
&& cmake .. -DBUILD_GMOCK=OFF && make && cd ${WORKDIR}

# Load repo into image
# Copy repo source into container
COPY . ${WORKDIR}

# Run static analysis
CMD pmccabe *.cpp -v && \
cccc --lang=c++ --outdir=report *.cpp
# Assure Unix linefeed for all files
RUN find . -type f -print0 | xargs -0 dos2unix --

# Build project
CMD sh -c ${WORKDIR}/test_runner.sh
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ The game will randomly-select a 5-letter word and you have unlimited guesses to
To use the project development environment, build the docker image using:

```
docker build -t cpp-analysis .
docker build -t cpp-container .
```

To run static analysis in the dev container:

```
docker run -it cpp-analysis
docker run -it cpp-container
```

To bind file changes between the host and container:

```
docker run -v "$(pwd)":/usr/src -it cpp-analysis
docker run -v "$(pwd)":/usr/src -it cpp-container
```
2 changes: 1 addition & 1 deletion dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// initiate word dictionary from file .wordler.data and store them as a
// list of upper case letters
dictionary::dictionary(){
dictionary_file = ".wordler.data" // default file
dictionary_file = ".wordler.data"; // default file
load_dictionary(dictionary_file);
}

Expand Down
5 changes: 5 additions & 0 deletions test_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

apt-get -y install pmccabe
pmccabe -v *.cpp
make clean && make

0 comments on commit df32b2e

Please sign in to comment.