Commit b0c301a7 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

- Move the content of Config in the `docker` directory.

- Add in CI a step to generate the Fedora image for TP.
- In the main README, add a brief explanation about the Docker command.
- In TP, reduce the README as the relevant informations is now given elsewhere.
parent 9e29ad97
......@@ -27,4 +27,18 @@ build_docker_full:
- docker build -f docker/Dockerfile_full -t $CI_REGISTRY/$CI_PROJECT_PATH/xeus-cling-and-compilers:${TAG} -t $CI_REGISTRY/$CI_PROJECT_PATH/xeus-cling-and-compilers:latest .
- docker container prune
- docker push $CI_REGISTRY/$CI_PROJECT_PATH/xeus-cling-and-compilers:${TAG}
- if [ "${UPDATE_LATEST_TAG}" == "True" ]; then docker push $CI_REGISTRY/$CI_PROJECT_PATH/xeus-cling-and-compilers:latest; fi
\ No newline at end of file
- if [ "${UPDATE_LATEST_TAG}" == "True" ]; then docker push $CI_REGISTRY/$CI_PROJECT_PATH/xeus-cling-and-compilers:latest; fi
build_fedora:
stage: build
retry: 2
only:
- web
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# Latest is always generated but not pushed if ${UPDATE_LATEST_TAG} is not "True"
- docker build -f docker/Dockerfile_full -t $CI_REGISTRY/$CI_PROJECT_PATH/fedora_for_tp:${TAG} -t $CI_REGISTRY/$CI_PROJECT_PATH/fedora_for_tp:latest .
- docker container prune
- docker push $CI_REGISTRY/$CI_PROJECT_PATH/fedora_for_tp:${TAG}
- if [ "${UPDATE_LATEST_TAG}" == "True" ]; then docker push $CI_REGISTRY/$CI_PROJECT_PATH/fedora_for_tp:latest; fi
\ No newline at end of file
......@@ -182,9 +182,6 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Dockerfiles have also been provided for [gcc](./Docker/Dockerfile.fedora.gcc) and [clang](./Docker/Dockerfile.fedora.clang) settings.\n",
"\n",
"\n",
"### macOS\n",
"\n",
"* Install XCode from the AppStore\n",
......
This directory includes several utilities used in the TPs and demos...
The Dockerfile here is not meant to be used directly but the ones for TPs and the demo about third party warnings are built upon it.
To build it, run:
````
docker build -t formation_cpp_docker_base .
````
\ No newline at end of file
# ----------------------------------------------------------------------------
# Zshrc
# Author : Grubly
# Patched by : Milipili, f00ty
# ----------------------------------------------------------------------------
# --------------------------------------------------------------- Settings ---
USER=`whoami`
OS=`uname -s`
MYEDITOR="vim"
HISTSIZE=10000
export LC_ALL='en_US.UTF-8'
# ------------------------------------------------------ ZSH Configuration ---
if [ -f /etc/profile ]; then
source /etc/profile 2>/dev/null >/dev/null
fi
## Am I a special user ??
if (( EUID == 0 )); then
superUser="yes";
else
groups | egrep "wheel|adm|staff|sys|es" > /dev/null
if [ "$?" -eq 0 ]; then
superUser="yes";
else
superUser="no";
fi;
fi;
## Eterm is not recognised by most OSes
if [[ $TERM = "Eterm" ]] ; then
case $OS in
Linux)
export TERM=Eterm
;;
NetBSD)
export TERM=xterm
;;
*)
export TERM=xterm-color
;;
esac
fi
## xterm is not recognized by NetBSD (1.6)
if [[ $TERM = "xterm-color" ]] ; then
case $OS in
NetBSD)
export TERM=xterm
;;
esac
fi
# Default umask
umask 022
if [ "$OS" = 'FreeBSD' ]; then
export EDITOR="/usr/local/bin/$MYEDITOR"
else
export EDITOR="/usr/bin/$MYEDITOR"
fi
addExportPath()
{
if [ -d "$1" ] ; then
if [ ! "$2" = "" -a -d "$2" ]; then
export PATH="$2:$PATH"
fi
export PATH="$1:$PATH"
fi
}
addExportPath '/sw/bin' '/sw/sbin'
addExportPath '/usr/bin' '/usr/sbin'
addExportPath '/bin' '/sbin'
addExportPath '/usr/local/bin' '/usr/local/sbin'
addExportPath '/opt/local/bin' '/opt/local/sbin'
# Misc options
setopt correct
setopt correct_all
setopt auto_cd
setopt hist_ignore_dups
setopt auto_list
setopt append_history
setopt auto_param_keys
setopt auto_param_slash
setopt bg_nice
setopt complete_aliases
setopt equals
setopt extended_glob
setopt hash_cmds
setopt hash_dirs
setopt mail_warning
setopt magic_equal_subst
setopt numericglobsort
setopt pushd_ignore_dups
setopt printeightbit
unsetopt beep
# Filename suffixes to ignore during completion
#fignore=(.o .c~ .pro)
## Prevent CVS/SVN files/directories from being completed
#zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
#zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'
#zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)svn'
#zstyle ':completion:*:cd:*' ignored-patterns '(*/)#svn'
# ignore patterns you don't have
zstyle ':completion:*:functions' ignored-patterns '_*'
## set colors for GNU ls ; set this to right file
if [ "$SHELL" = '' ]; then # fixing
export SHELL=`which zsh`
fi
my_ls=ls
which gls > /dev/null
if [ $? -eq 0 ]; then
my_ls=gls
fi
which dircolors > /dev/null
if [ $? -eq 0 ]; then
#eval `dircolors`
export LS_COLORS="no=00:fi=00:di=00;36:ln=00;32:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:"
ls=$my_ls' -F --color=always'
else
## dircolors not availaible, try gdircolors
which gdircolors > /dev/null
if [ $? -eq 0 ]; then
eval `gdircolors -b | sed 's/;34/;36/g'`
ls=$my_ls' --color=auto'
alias df='gdf'
else
## GNU ls not available, using other one.
export LS_COLORS="no=00:fi=00:di=00;36:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:"
case $OS in
FreeBSD)
export BLOCKSIZE=K
export CLICOLOR=enable
autoload -U is-at-least
export LS_COLORS="gxfxBxcxbxegedabagacad"
ls='ls -F'
;;
OpenBSD|NetBSD|Darwin|SunOS)
ls='ls -F -G'
;;
esac
fi
fi
# Doesn't work here!
#export LSCOLORS="$LS_COLORS"
# Aliases
alias l='ls -lh'
alias ll='ls -l'
alias la='ls -A'
# Good prompts
autoload -U colors
colors
path_color="yellow"
sym_color="cyan"
time_color="white"
err_color="red"
num_color="blue"
computer_color="cyan"
if [ "$USER" = "root" ]; then
login_color="red"
else
login_color="green"
fi
cpath="%B%{$fg[$path_color]%}%30<...<%~%b"
psym="%{$fg[$sym_color]%}%%"
plogin="%{$fg[$login_color]%}[$USER]"
time="%{$fg[$time_color]%}%T"
error="%B%{$fg[$err_color]%}Err %?%b"
reset="%{$reset_color%}"
num="%{$fg[$num_color]%}#%h"
computer="%b%{$fg[$computer_color]%}`hostname | cut -d"." -f1`%B"
PS1="$computer $plogin $cpath $psym $reset"
RPS1="%(?,$time,$error) $num$reset"
# Completion options
autoload mere zed zfinit
autoload incremental-complete-word
zle -N incremental-complete-word
# Always use emacs-mode
bindkey -e
# Bindkeys, easier life.
bindkey i incremental-complete-word
bindkey  history-incremental-search-backward
bindkey \[1~ beginning-of-line
bindkey \[7~ beginning-of-line
bindkey \[4~ end-of-line
bindkey  beginning-of-line
bindkey  end-of-line
bindkey kill-line
bindkey  kill-whole-line
bindkey  yank
bindkey  vi-forward-word
bindkey  vi-backward-word
autoload insert-files
autoload nslookup
autoload predict-on
autoload compinit
autoload complist
compinit
zstyle ':completion:*' format '%{%}--- %{%}%d%{%}'
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _complete _correct _approximate
zstyle ':completion:*' group-name ''
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'l:|=* r:|=*' 'r:|[
._-]=* r:|=*'
zstyle ':completion:*' max-errors 2
zstyle ':completion:*' menu select=5
zstyle ':completion:*' original true
zstyle ':completion:*' squeeze-slashes true
zstyle ':completion:*' verbose true
zstyle ':completion:*:processes' list-colors '=(#b)(?????)(#B)?????????????????????????????????([^ ]#/)#(#b)([^ /]#)*=00=01;31=01;33'
zstyle ':completion:*:processes' command 'ps -au$USER'
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' force-list always
zstyle ':completion:*:rm:*' ignore-line yes
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
zstyle ':completion:*:*:xdvi:*' menu yes select
zstyle ':completion:*:*:xdvi:*' file-sort time
# On the fly hostname list
if [ -f "${HOME}/.ssh/known_hosts" ]; then
allprevioushosts="`cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e 's/,.*//g' | uniq | grep -v "\[" | tr '\n' ' '`"
else
allprevioushosts=''
fi
zstyle '*:hosts' hosts localhost `echo ${allprevioushosts}`
export EDITOR=$MYEDITOR
# LS
case $OS in
FreeBSD) alias ls="$ls -w";;
Darwin|Linux) alias ls="$ls -v";;
OpenBSD|NetBSD|SunOS) alias ls="$ls" ;;
*) alias ls="$ls" ;;
esac
# Aliases
alias l='ls -lh'
alias ll='ls -l'
alias la='ls -A'
alias rm='rm -i'
if [ "$OS" = 'Darwin' ]; then # Hack pour Terminal
export TERM='xterm-color'
fi
if [ "$OS" = 'Linux' ]; then
if [ ! "`which htop`" = '' ]; then
alias top="htop"
fi
alias grep="grep --color"
fi
# Alias
alias v="vim"
if [ "$OS" = 'Darwin' ]; then
alias log="tail -n 20 /var/log/system.log"
else
alias log="tail -n 20 /var/log/messages"
fi
echo
echo " Welcome "$USER" on `hostname` !"
echo
# Faire fonctionner backspace dans tous les cas
case $TERM in
*xterm*|rxvt|(dt|k|E)term)
bindkey '^?' backward-delete-char
bindkey "^[[3~" delete-char
;;
esac
# Good for you :)
if [ "$TERM" '!=' 'linux' ]; then
precmd() {print -Pn "\e]0;%n@%m: %~\a"}
fi
......@@ -50,7 +50,7 @@ conda activate training_cpp_2021
Don't forget to activate it each time you intend to run the lecture!
**WARNING** At the moment, Conda packaging is broken for the most recent version of macOS (11.3). A [ticket](https://github.com/jupyter-xeus/xeus-cling/issues/403) has been issued and is under work; in the meanwhile use Binder (or a workaround through a Docker image).
**WARNING** At the moment, Conda packaging is broken for the most recent version of macOS (11.3). A [ticket](https://github.com/jupyter-xeus/xeus-cling/issues/403) has been issued and is under work; in the meanwhile use Binder or a local Docker image (see below)
* Then you can run the notebook by going **into its root directory** (or internal links won't work...) in a terminal and typing:
......@@ -64,21 +64,29 @@ __BEWARE__: I **strongly advise** to use a dedicated environment for the noteboo
__NOTE__: It is possible to use the notebooks directly from some IDEs like [VSCode](https://gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/-/wikis/home#using-notebooks-with-vscode).
### Docker machine
### Docker
It is possible to execute the notebooks from a Docker machine by simply typing:
It is possible to execute the notebooks in a Docker container by simply typing:
````
docker run -v $PWD:/home/formation/gettingstartedwithmoderncpp -p 8888:8888 registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/xeus-cling:latest
docker run -v $PWD:/home/formation/gettingstartedwithmoderncpp -p 8888:8888 --cap-drop=all registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/xeus-cling:latest
````
or
````
docker run -v $PWD:/home/formation/gettingstartedwithmoderncpp -p 8888:8888 registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/xeus-cling-and-compilers:latest
docker run -v $PWD:/home/formation/gettingstartedwithmoderncpp -p 8888:8888 --cap-drop=all registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/xeus-cling-and-compilers:latest
````
Then just type [http://localhost:8888/](http://localhost:8888/) in your browser.
Few hints for those not familiar with Docker:
* `-v` creates a mapping between local folder and the /home/formation/gettingstartedwithmoderncpp folder in the container; this enables you to edit the file from your comfy local environment and see the file edited this way in the Docker container.
* `--cap-drop=all` is a safety when you're running a Docker image not built by yourself: you're essentially blocking the few remaining operations that might impact your own environment that Docker lets by default open with the run command.
* `-p` gives the port mapping between the Docker image and your local environment.
The lengthy `registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/xeus-cling-and-compilers` is the name of the Docker **image**, if this image is not present locally in your environment Docker will try to fetch it from a *registry* on the Inria Gitlab.
Then just type [http://localhost:8888/](http://localhost:8888/) in your browser to run the notebooks.
### BinderHub
......
# How to use Docker for TP?
The more natural to run the TP is to set up your local environment with a compiler and a development environment (an IDE, git, etc...)
First of all, make sure [Docker](https://www.docker.com/) is properly installed and running.
However if need be we prepared a Docker image which includes a very basic environment with the minimum required to be able to run the TPs.
## Getting the image
The image is based on Fedora and is created through this [Dockerfile](../docker/Dockerfile.fedora).
Then to get the relevant image you may either:
### Build the image from the provided Dockerfile
Type in a terminal (in the same folder this README is):
````
docker build -t tp_formation_cpp .
````
This may take few minutes.
### Or fetching it from the gitlab registry
Type in a terminal (provided you have an account on the [Inria gitlab](https://gitlab.inria.fr) - if not you may create one easily):
To run it type:
````
docker login registry.gitlab.inria.fr
docker pull registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/tp_formation_cpp:latest
docker run -it -v $PWD:/home/formation/gettingstartedwithmoderncpp --cap-drop=all registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/fedora_for_tp:latest
````
## Running the image
Run *from the TP directory of the project* the command:
````
docker run -v $PWD:/Codes/TP --cap-drop=all -it tp_formation_cpp
````
For those of you not familiar with Docker:
* `-v` creates a mapping between local folder and the /Codes/ThirdPartyWarning folder in the container; this enables you to edit the file from your comfy environment and see the file edited this way in the Docker container.
* `--cap-drop=all` is a safety when you're running a Docker image not built by yourself: you're essentially blocking the few remaining operations that might impact your own environment that Docker lets by default open with the run command.
* `-it` tells we want an interactive session: your terminal session will place you inside the container (here a Fedora environment).
Most options have already been covered in the [main README](../README.md); the only new one is:
`tp_formation_cpp` is a Docker **image**; the instantiation of this image obtained after the run command is a **container**. All the modifications you may do in the container won't be kept when you leave it, except for the files that will have been written in your own filesystem thanks to the `-v` option.
- `-it` which specifies the container must be run in interactive mode (i.e. you get a prompt to a terminal inside the Docker environment).
......@@ -3,8 +3,11 @@ LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
RUN (dnf update -y && dnf upgrade -y -q)
RUN dnf install -y git cmake clang gcc gcc-c++ ninja-build which zsh hostname make && dnf clean packages
RUN dnf install -y git cmake clang gcc gcc-c++ ninja-build which hostname make && dnf clean packages
COPY zshrc /root/.zshrc
# Create non root user
ENV USER "formation"
RUN useradd --create-home ${USER}
USER ${USER}
ENTRYPOINT ["zsh"]
WORKDIR /home/${USER}/gettingstartedwithmoderncpp
\ No newline at end of file
To build docker images, the command shall be launched in the project root folder.
To build docker images, the command shall be launched in the project root folder. They may also be created through CI/CD using Gitlab Web interface (see [here](../CI.md)).
```
docker build -f docker/<dockerfile> .
......@@ -6,8 +6,9 @@ docker build -f docker/<dockerfile> .
The .dockerignore file is used to reduce docker image size by keeping the docker context to minimum.
There are two Dockerfiles here:
There are several Dockerfiles here:
- [Dockerfile], which creates an image with a Conda environment to run properly Xeus-cling.
- [Dockerfile-full], which creates an image with a Conda environment to run properly Xeus-cling and installs as well local compilers so that they may be invoked from the notebooks (for the 6-InRealEnvironment part).
- [Dockerfile.fedora] which provides an environment with both clang and gcc installed. This notebook is not intended to run the notebooks but may be used to run the TPs.
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