Skip to content

Commit

Permalink
fix Docker info
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryMaciek committed Aug 4, 2023
1 parent 14c989e commit 04f4092
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ an isolated environment, just for this project:
If you have no experience with Conda environments, read about them
[under this address](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html).

### local Docker container

We have additionally prepared a development/execution Docker image which one may use in order to
work on our project in a fully encapsulated environment (that is: a container).
Assuming the Docker Engine is running locally please build the image with:
```
docker build -t hypercomplex:latest -f Dockerfile-dev .
```
Once the process is finished start & enter the container with:
```
docker run --name hypercomplex -e HOSTUID=`id -u $USER` -p 8888:8888 -v {HOST_PATH_TO_HYPERCOMPLEX}:/hypercomplex -it fuzzyreg:latest
```
Watch out! Due to Docker's specifics they need to be executed as `root` user;
[alternatively, see here](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user).
Recall that all data generated inside the container (with the exception of the mounted volume) are **not** persistent.
If you'd like your data don't perish into oblivion after you stop the container
check out [Docker documentation on storage mechanisms](https://docs.docker.com/storage/).
### Ephemeral development environment
(╯°□°)╯︵ ┻━┻
Expand Down
35 changes: 34 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ifeq ($(UNAME_S),Darwin)
INCLUDE_PREFIX = /usr/local/include
endif

.PHONY: help install uninstall test lint docs build clean
.PHONY: help install uninstall test lint docs build clean image container

# =============================================================================
# Print available commands
Expand All @@ -35,6 +35,8 @@ help:
@echo "docs - generate project's documentation (requires doxygen)"
@echo "build - build conda package (requires conda-build)"
@echo "clean - remove all dev artifacts"
@echo "image - build Docker image (requires Docker deamon running)"
@echo "container - start interactive Docker container (requires image)"

# =============================================================================
# Install
Expand Down Expand Up @@ -109,3 +111,34 @@ clean:
@find . -type f -name '*.DS_Store' -delete
@rm -rf docs/html docs/latex
@rm -f test

# =============================================================================
# Image
# =============================================================================

# Build Docker image
image:
@# Build docker image
@if [ $$(docker ps &> /dev/null; echo $$?) -eq 0 ]; then\
docker rm hypercomplex &> /dev/null;\
sleep 1;\
docker rmi hypercomplex:latest &> /dev/null;\
docker build -t hypercomplex:latest -f Dockerfile .;\
else \
echo "Docker deamon is not running OR the current user requires higher privileges.";\
fi

# =============================================================================
# Container
# =============================================================================

# start Docker container
container:
@# Run a docker container
@if [ $$((docker images | grep hypercomplex) &> /dev/null; echo $$?) -eq 0 ] \
; then\
docker rm hypercomplex &> /dev/null;\
docker run --name hypercomplex -e HOSTUID=`id -u $$USER` -p 8888:8888 -it -v $$PWD:/hypercomplex hypercomplex:latest;\
else \
echo "Docker deamon isn't running OR hypercomplex image isn't available OR the current user requires higher privileges.";\
fi

0 comments on commit 04f4092

Please sign in to comment.