Mentions légales du service

Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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
%% Cell type:markdown id: tags:
# [Getting started in C++](./) - [C++ in a real environment](./0-main.ipynb) - [Set up environment](./1-SetUpEnvironment.ipynb)
%% Cell type:markdown id: tags:
<h1>Table of contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#Introduction" data-toc-modified-id="Introduction-1">Introduction</a></span></li><li><span><a href="#Installing-a-compiler" data-toc-modified-id="Installing-a-compiler-2">Installing a compiler</a></span><ul class="toc-item"><li><span><a href="#Ubuntu-/-Debian" data-toc-modified-id="Ubuntu-/-Debian-2.1">Ubuntu / Debian</a></span><ul class="toc-item"><li><span><a href="#Clang" data-toc-modified-id="Clang-2.1.1">Clang</a></span></li><li><span><a href="#Default-g++" data-toc-modified-id="Default-g++-2.1.2">Default g++</a></span></li><li><span><a href="#More-recent-gcc" data-toc-modified-id="More-recent-gcc-2.1.3">More recent gcc</a></span></li></ul></li><li><span><a href="#Fedora" data-toc-modified-id="Fedora-2.2">Fedora</a></span><ul class="toc-item"><li><span><a href="#g++" data-toc-modified-id="g++-2.2.1">g++</a></span></li><li><span><a href="#clang++" data-toc-modified-id="clang++-2.2.2">clang++</a></span></li></ul></li><li><span><a href="#macOS" data-toc-modified-id="macOS-2.3">macOS</a></span></li></ul></li><li><span><a href="#STL" data-toc-modified-id="STL-3">STL</a></span></li><li><span><a href="#Editor" data-toc-modified-id="Editor-4">Editor</a></span></li><li><span><a href="#Software-configuration-manager" data-toc-modified-id="Software-configuration-manager-5">Software configuration manager</a></span></li><li><span><a href="#Build-system" data-toc-modified-id="Build-system-6">Build system</a></span></li></ul></div>
%% Cell type:markdown id: tags:
## Introduction
I will present here briefly how to set up a minimal development environment... only in Unix-like systems: sorry for Windows developers, but I have never set up a Windows environment for development.
This will explain installation for two mainstreams compilers: [GNU compiler for C++](https://en.wikipedia.org/wiki/GNU_Compiler_Collection) and [clang++](https://en.wikipedia.org/wiki/Clang).
## Installing a compiler
### Ubuntu / Debian
%% Cell type:markdown id: tags:
#### Clang
To install `clang` you need to specify explicitly the required version, e.g.:
%% Cell type:code id: tags:
``` C++17
// In a terminal
sudo apt-get install -y clang++-11
```
%% Cell type:markdown id: tags:
#### Default g++
%% Cell type:code id: tags:
``` C++17
// In a terminal
sudo apt-get install -y g++
```
%% Cell type:markdown id: tags:
#### More recent gcc
However, Ubuntu is rather conservative and the version you get might be a bit dated and it might be problematic if you intend to use the bleeding-edged features from the latest C++ standard (even if it's now better than what it used to be: with Ubuntu 18.04 you get the decent g++-7.3 now and gcc-9.3 with 20.04).
To get a more recent version, you need to use this [PPA](https://launchpad.net/ubuntu/+ppas):
%% Cell type:code id: tags:
``` C++17
// In a terminal
// To enable `add-apt-repository` command; probably not required in a full-fledged installation
// but you will need it in a Docker image for instance.
sudo apt-get install --no-install-recommends -y software-properties-common
// Adding PPA and making its content available to `apt`.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
// Installing the more recent gcc; which is 10 at the time of this writing (April 2021)
sudo apt-get install -y g++-10
```
%% Cell type:markdown id: tags:
And to tell the system which version to use, the command is:
%% Cell type:code id: tags:
``` C++17
// In a terminal
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
```
%% Cell type:markdown id: tags:
More realistically, you will install gcc and perhaps gfortran as well; the following command make sure all are kept consistent (you do not want to mesh gcc 7 with g++ 9 for instance...):
%% Cell type:code id: tags:
``` C++17
// In a terminal
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
--slave /usr/bin/g++ g++ /usr/bin/g++-10
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-10
```
%% Cell type:markdown id: tags:
### Fedora
For development purposes I rather like Fedora, which provides more recent versions than Ubuntu and also a simple clang installation.
%% Cell type:markdown id: tags:
#### g++
%% Cell type:code id: tags:
``` C++17
// In a terminal
sudo dnf install -y gcc gcc-c++ gcc-gfortran
```
%% Cell type:markdown id: tags:
#### clang++
%% Cell type:code id: tags:
``` C++17
// In a terminal
sudo dnf install -y clang
```
%% Cell type:markdown id: tags:
Dockerfiles have also been provided for [gcc](./Docker/Dockerfile.fedora.gcc) and [clang](./Docker/Dockerfile.fedora.clang) settings.
### macOS
* Install XCode from the AppStore
* Install if requested the command line tools
This will install _Apple Clang_ which is a customized version of `clang`. Unfortunately, Apple stopped providing the version of mainstream clang it is built upon; it's therefore more difficult to check if a new standard feature is already supported or not.
It is also possible to install gcc on macOS; I personally use [Homebrew](https://brew.sh) to do so.
%% Cell type:markdown id: tags:
## STL
Besides the compiler, you may also choose which implementation of the STL you want to use. There are two mainstream choices:
- `libstdc++`, which is the STL provided along gcc by GNU. This is the default choice for many Linux distro, and there is fat chance the binaries, libraries and share libraries in your package system was compiled with this one.
- `libc++`, which is the STL provided along clang by LLVM. It is the default choice on macOS, and was until recently a pain to use with Ubuntu (according to Laurent it is much better now in Ubuntu 20.04.
Both are pretty solid choices:
- Going with `libstdc++` is not a bad idea if you're using with your code libraries from your package manager that uses up this STL implementation (likely in a Linux distro).
- Going with `libc++` along with clang++ seems rather natural as well.
%% Cell type:markdown id: tags:
Just a note for compatibility: `libc++` tends to provide more `include` directive in its header files than `libstdc++`. So don't be astonished if your code compiles well with `libc++` but complains about an unknown symbol from STL with `libstdc++` (and the patch is simply to use the missing include - a tool such as IncludeWhatYouUse would have underlined the missing include even when using `libc++`).
%% Cell type:markdown id: tags:
## Editor
%% Cell type:markdown id: tags:
You will need a [source code editor](https://en.wikipedia.org/wiki/Source_code_editor) to write your code; usually your system will provide a very basic one and you may be able to install another on your own.
From my experience, there are essentially two types of developers:
- Those that revel in using [VIM](https://en.wikipedia.org/wiki/Vim_(text_editor)) **or** [emacs](https://en.wikipedia.org/wiki/Emacs), which are lightweight editors that have been around for decades and are rather powerful once you've climbed a (very) steep learning curve.
- Those that will like [integrated development environment](https://en.wikipedia.org/wiki/Integrated_development_environment) more, which provides more easily some facilities (that can often be configured the hard way in the aforementioned venerable text editors) but are more resource-intensive.
I suggest you take whichever you're the most comfortable with and don't bother about the zealots that tell you their way is absolutely the best one.
_Vim_ and _emacs_ are often either already installed or available easily with a distribution package (_apt_, _dnf_, etc...); for IDEs here are few of them:
* [Visual Studio Code](https://code.visualstudio.com/), which gained traction in last few years and is one of the most sizeable GitHub project. This is an open-source and multi-platform editor maintained by Microsoft, not to be confused with [Visual Studio](https://visualstudio.microsoft.com/?rr=https%3A%2F%2Fwww.google.com%2F) - also provided by Microsoft on Windows (and with a fee).
* [CLion](https://www.jetbrains.com/clion/) by JetBrains is also a rising star in IDEs; a free version is available for students.
* [Eclipse CDT](https://www.eclipse.org/cdt/) and [NetBeans](https://netbeans.org/) are other IDEs with more mileage.
* [QtCreator](https://www.qt.io/qt-features-libraries-apis-tools-and-ide) is not just for Qt edition and might be used as a C++ IDE as well.
* [XCode](https://developer.apple.com/xcode) is the editor provided by Apple on macOS.
* [KDevelop](https://www.kdevelop.org/) is the IDE from the KDE project. Combination of an advanced editor with semantic code analysis.
* [JupyterLab](https://jupyter.org/) this very same notebook lab can be used as IDE after the last improvements and extensions added, [see](https://towardsdatascience.com/jupyter-is-now-a-full-fledged-ide-c99218d33095).
%% Cell type:markdown id: tags:
## Software configuration manager
A [software configuration manager](https://en.wikipedia.org/wiki/Software_configuration_management), sometimes abbreviated as **SCM**, is important when you're writing code that is meant to stay at least a while (and very handy even if that is not the case).
It is useful not only when you're working with someone else: if at some point you're lost in your code and don't understand why what was working perfectly few hours ago is now utterly broken it is really helpful to be able to compare what has changed since this last commit.
The most obvious choice for a SCM is [git](https://git-scm.com) which is now widely abroad and has become the _de facto_ standard. _git_ is extremely versatile but you can already do a lot of version control with around 10 commands so the learning curve is not as steep as you may fear.
git is generally already installed on your system or readily available through your package manager.
%% Cell type:markdown id: tags:
## Build system
Handling properly the compilation of the code is not an easy task: many tutorial skip entirely the topic or just show a very basic example that is very far removed from a real project with potentially many third-party dependencies. This is understandable (and I will mostly do the same): using properly a build system is not trivial and may be the topic on a full lecture of its own.
The usual possibilities are:
* Build system provided by your IDE. Might be easier to use (definitely the case for XCode which I'm familiar with once you grasp how it is intended to work) but you bind your potential users to use the same IDE (even if now some relies upon CMake).
* [Makefile](https://en.wikipedia.org/wiki/Makefile) is the venerable ancestor, which is really too painful to write and not automated enough for my taste.
* [CMake](https://cmake.org) is the build system probably with the more traction now; it is a cross-platform build system which is rather powerful but not that easy to learn. Official documentation is terse; you may try [this](https://cliutils.gitlab.io/modern-cmake/) or [that](https://cgold.readthedocs.io/en/latest/) to understand it better. Please notice CMake was heavily changed when switching from version2 to version 3; take a recent documentation if you want to learn "modern" CMake. The principle of CMake is to provide a generic configuration that may be used for different build tools: by default you generate a Makefile, but you may choose another generator such as Ninja (see below) or a specific IDE.
* [meson](https://mesonbuild.com/) is a more recent alternative which aims to be simpler to use than CMake. Never used it so can't say much about it.
* [SCons](https://www.scons.org/) is a build system built upon Python which lets you write your own Python functions in the build system. The concept is appealing, but the actual use is actually dreadful and the provided build is much slower than what other build system provides. Avoid it!
* [Ninja](https://ninja-build.org) is presented on this website as _a small build system with a focus on speed. It differs from other build systems in two major respects: it is designed to have its input files generated by a higher-level build system, and it is designed to run builds as fast as possible_. It is my favorite generator to use with CMake; meson also enables usage of Ninja under the hood.
%% Cell type:markdown id: tags:
© _CNRS 2016_ - _Inria 2018-2021_
_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_
_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_
......
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.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment