Commit 6a773851 authored by Jolie Roiseux's avatar Jolie Roiseux Committed by Andrei Muresan
Browse files

Containerize builds to enable cross-platform use

See README > Docker for usage details
parent 2cef1130
ntp
scripts
bin
lib
obj
......@@ -2,6 +2,7 @@
*.exe
\#*#
*~
*.zip
.DS_Store
build
*.log
......
......@@ -6,6 +6,7 @@ stages:
variables:
DOCGEN_IMAGE: "$CI_REGISTRY/phaar/$CI_PROJECT_NAME/docgen"
VANWFTK_IMAGE: "$CI_REGISTRY/phaar/$CI_PROJECT_NAME/vanwftk"
# Checks code formatting & style
lint:
......@@ -33,6 +34,25 @@ build:docgen_image:
- changes:
- Dockerfile.docgen
# Builds & publishes VANWFTK container image the project's container registry
build:vanwftk_image:
stage: build
tags:
- docker-runner
image: docker
services:
- docker:dind
script:
- docker build -t "$VANWFTK_IMAGE:$CI_COMMIT_REF_SLUG" -f Dockerfile .
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker push "$VANWFTK_IMAGE:$CI_COMMIT_REF_SLUG"
rules:
- changes:
- "code/*"
- "macros/*"
- Dockerfile
- Makefile
# Generates docs and stashes the resulting artifacts
docs:generate:
stage: docs
......
FROM rootproject/root
RUN apt-get update && apt-get install -y git build-essential rsync vim
RUN mkdir /home/vanwftk
WORKDIR /home/vanwftk
RUN git clone https://bitbucket.org/tmidas/midas --recursive
ENV MIDASSYS /home/vanwftk/midas
WORKDIR /home/vanwftk/midas
RUN make mini && \
ln -s linux/lib lib && \
ln -s linux/bin bin
WORKDIR /home/vanwftk
RUN git clone https://bitbucket.org/tmidas/rootana
ENV ROOTANASYS /home/vanwftk/rootana
WORKDIR /home/vanwftk/rootana
RUN git checkout rootana-2020-03-a && \
sed -i 's/CXXFLAGS = -g -O2 -Wall -Wuninitialized -I\.\/include/CXXFLAGS = -g -O2 -Wall -Wuninitialized -I\.\/include -fPIC/g' /home/vanwftk/rootana/Makefile && \
make
WORKDIR /home/vanwftk
COPY . vanwftk
WORKDIR /home/vanwftk/vanwftk
RUN make clean && make
CMD ["/bin/bash"]
......@@ -7,7 +7,7 @@ GFLAGS = -g -O0
# CFLAGS = -c -fPIC $(GFLAGS) $(shell root-config --cflags) -I. -I/home/exo/packages/hdf5-1.8.13/include -I$(MIDASSYS)/include -I$(ROOTANASYS)/include
CFLAGS = -c -fPIC $(GFLAGS) $(shell root-config --cflags) -I. -I$(MIDASSYS)/include -I$(ROOTANASYS)/include
# LFLAGS = $(GFLAGS) $(shell root-config --libs) -lMinuit -L /home/exo/packages/hdf5-1.8.13/lib -lhdf5 -lhdf5_cpp -lz -lm $(ROOTANALIBS) $(MIDASLIBS)
LFLAGS = $(GFLAGS) $(shell root-config --libs) -lMinuit -lz -lm $(ROOTANALIBS) $(MIDASLIBS)
LFLAGS = $(GFLAGS) $(shell root-config --libs) $(ROOTANALIBS) $(MIDASLIBS) -lMinuit -lz -lm
all: PF lib
......@@ -16,17 +16,21 @@ PF : bin/PulseFinding.exe
lib : lib/libSipmAnalysis.so
lib/libSipmAnalysis.so : obj/Waveform.o obj/WaveformProcessor.o obj/LecroyFile.o obj/V1730File.o obj/DataFile.o obj/RootDict.o #obj/LecroyHdfFile.o
mkdir -p $(@D)
g++ -shared -fPIC -o lib/libSipmAnalysis.so $^ $(LFLAGS)
bin/PulseFinding.exe : obj/PulseFinding.o obj/LecroyFile.o obj/V1730File.o obj/WaveformProcessor.o obj/Waveform.o obj/DataFile.o #obj/LecroyHdfFile.o
mkdir -p $(@D)
g++ -o bin/PulseFinding.exe $^ $(LFLAGS)
obj/RootDict.o : code/Waveform.h code/LecroyFile.h code/V1730File.h code/WaveformProcessor.h code/DataFile.h code/Linkdef.h # code/LecroyHdfFile.h
# rootcint -f code/RootDict.cxx -c -I/home/deap/nEXO/packages/hdf5-1.8.13/hdf5/include -I$ROOTANADIR $^
rootcint -f code/RootDict.cxx -c -I$(ROOTANADIR) $^
mkdir -p $(@D)
g++ -c -o $@ code/RootDict.cxx $(CFLAGS)
obj/%.o: code/%.cxx
mkdir -p $(@D)
g++ -c -o $@ $< $(CFLAGS)
format:
......@@ -41,4 +45,4 @@ docs:
doxygen Doxyfile
clean:
rm -f obj/* bin/* lib/*
rm -rf obj bin lib
\ No newline at end of file
# Vancouver Waveform Analysis Toolkit
## Overview
# Overview
A software suite for processing waveform data, designed to help particle physics researchers detect and analyze pulses.
## Usage
# Usage
*Coming soon*
Refer to the [Docker](#docker) section below for instructions on setting up and running the project locally.
## Code Style
# Code Style
This project integrates with `clang-format` to ensure that the source code adheres to the [LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html) for C++.
Install `clang-format` locally via Homebrew (MacOS) or your preferred package manager. Run `make lint` to detect any style errors, or just run `make format` before making a commit to let the tool automatically format your code. The CI pipeline running for every commit will reject code that does not pass the linting step, ensuring that all of the code merged to the `master` branch follows the standard style.
## Other Documentation
# Docker
## Prerequisites
* Docker is installed and running
* [Get Docker](https://docs.docker.com/get-docker/)
* Your local `vanwftk` directory contains the `ntp` directory with data files
* In a terminal, navigate to `vanwftk/scripts`
## Commands
### Pull
The container image needed to run and develop the project is hosted in our GitLab project's private registry. Every branch, including `master`, has an image built and published on every commit under a [tag](https://docs.docker.com/engine/reference/commandline/tag/) name matching the branch. Use the "Quick Start" button on the [Container Registry](https://gitlab.triumf.ca/phaar/vanwftk/container_registry) page in GitLab to authenticate yourself, then click on the `phaar/vanwftk/vanwftk` image to see all of the available versions. You may copy any of these tagged images' full names to download them via `docker pull`, but the run scripts documented below will automatically pull the latest image associated with your branch.
### Build
You only need to run this the first time you build the container as long as you haven't updated the Makefile.
```
./docker-build.sh
```
If you have made any changes to the Makefile, run this command before continuing:
```
./docker-build.sh --rebuild
```
### Run
The following includes steps from [Docker Hub - rootproject/root](https://hub.docker.com/r/rootproject/root) to enable graphics on each environment.
#### Linux:
1. Make sure you are in an X11 session
2. Run one of the following commands from `vanwftk/scripts`:
**To run as a basic user:**
```
./docker-run-linux.sh
```
**To run as a developer with live code updates:**
```
./docker-run-linux.sh --dev
```
From inside the container, run `make`.
#### OSX:
1. Make sure XQuartz is installed
2. Open XQuartz
3. Go to XQuartz > Preferences > Security
4. Tick the box "Allow connections from network clients"
5. Exit XQuartz
6. Run on of the following commands from `vanwftk/scripts`:
**To run as a basic user:**
```
./docker-run-osx.sh
```
**To run as a developer with live code updates:**
```
./docker-run-osx.sh --dev
```
From inside the container, run `make`.
# Other Documentation
- [How our documentation works](docs/DOCUMENTATION.md)
#!/bin/bash
IMAGE="registry.triumf.ca/phaar/vanwftk/vanwftk:$(git branch --show-current | sed 's/\//-/g')"
if [[ "$1" == "--rebuild" ]]; then
docker build --no-cache -t "$IMAGE" ..
else
docker build -t "$IMAGE" ..
fi
\ No newline at end of file
#!/bin/sh
PROJECT_ROOT_PATH="$(dirname "$(dirname "$(realpath "$0")")")"
CONTAINER_WORKDIR='/home/vanwftk/vanwftk'
if [ "$1" = '--dev' ]; then
PROJECT_DIR_MAPPING="${PROJECT_ROOT_PATH}/:${CONTAINER_WORKDIR}/"
else
PROJECT_DIR_MAPPING="${PROJECT_ROOT_PATH}/ntp:${CONTAINER_WORKDIR}/ntp"
fi
IMAGE="registry.triumf.ca/phaar/vanwftk/vanwftk"
TAG="$(git branch --show-current | sed 's/\//-/g')"
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "${IMAGE}:${TAG}" > /dev/null; then
echo "Using image tag '$TAG'..."
else
echo "Could not find an image associated with this branch; defaulting to 'master'"
TAG='master'
fi
docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -v "$PROJECT_DIR_MAPPING" -e DISPLAY="$DISPLAY" "${IMAGE}:${TAG}"
#!/bin/bash
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
PROJECT_ROOT_PATH="$(dirname "$(dirname "$(realpath "$0")")")"
CONTAINER_WORKDIR='/home/vanwftk/vanwftk'
ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost + "$ip"
if [[ "$1" == "--dev" ]]; then
PROJECT_DIR_MAPPING="${PROJECT_ROOT_PATH}/:${CONTAINER_WORKDIR}/"
else
PROJECT_DIR_MAPPING="${PROJECT_ROOT_PATH}/ntp:${CONTAINER_WORKDIR}/ntp"
fi
IMAGE="registry.triumf.ca/phaar/vanwftk/vanwftk"
TAG="$(git branch --show-current | sed 's/\//-/g')"
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "${IMAGE}:${TAG}" > /dev/null; then
echo "Using image tag '$TAG'..."
else
echo "Could not find an image associated with this branch; defaulting to 'master'"
TAG='master'
fi
docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -v "$PROJECT_DIR_MAPPING" -e DISPLAY="$ip":0 "${IMAGE}:${TAG}"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment