Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
(#55) Add support for using LaTeX in plots, also make some other chan…
Browse files Browse the repository at this point in the history
…ges:

* Install and precompile IJulia, PyPlot, and Plots;
* Change base image to Ubuntu;
* Add key bindings;
* Add Node.js and npm;
* Remove the tests from the Travis build.
  • Loading branch information
Pavel Sobolev authored Jul 4, 2020
1 parent 3695bb4 commit 904e918
Show file tree
Hide file tree
Showing 18 changed files with 349 additions and 186 deletions.
36 changes: 0 additions & 36 deletions .github/scripts/Build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,6 @@ EOF
echo -e '\n\e[1m\033[36mAnalyzing the image...\033[0m\n'
CI=true dive image

# Delete redundant build images
echo -e '\e[1m\033[36mDeleting redundant build images...\033[0m\n'
docker images -q | grep -E -v "$(docker images -q 'image')|$(docker images -q 'alpine')" | xargs docker rmi

# Run a container
echo -e '\n\e[1m\033[36mRunning a container...\033[0m\n'
docker run --name container -v /var/run/docker.sock:/var/run/docker.sock -d -t image

# Test if Zsh is installed
echo -e '\n\e[1m\033[36mTesting if Zsh is installed...\033[0m\n'
docker exec container zsh --version

# Open a docker socket for others group
echo -e '\n\e[1m\033[36mOpening a docker socket for others group...\033[0m\n'
sudo chmod o+rw /var/run/docker.sock

# Test if docker is installed (also check permissions)
echo -e '\e[1m\033[36mTesting if docker is installed...\033[0m\n'
docker exec container docker version

# Run hello-world in docker (also check permissions)
echo -e '\n\e[1m\033[36mRunning hello-world in docker...\033[0m\n'
docker exec container docker run hello-world

# Check if Jupyter is installed
echo -e '\e[1m\033[36mChecking if Jupyter is installed...\033[0m\n'
docker exec container jupyter --version

# Check if Julia is installed
echo -e '\n\e[1m\033[36mChecking if Julia is installed...\033[0m\n'
docker exec container julia --version

# Stop the container
echo -e '\n\e[1m\033[36mStopping the container...\033[0m\n'
docker stop container

else

# Print info
Expand Down
49 changes: 35 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# layers use docker's --squash option when building

# Base image
FROM alpine:3.12.0
FROM ubuntu:20.04

# Meta information
LABEL maintainer="Pavel Sobolev (https://github.com/Paveloom)"
Expand All @@ -11,35 +11,50 @@ LABEL description="This is an image containing paveloom's personal development e
LABEL github-repository="https://github.com/paveloom-d/dev"
LABEL docker-repository="https://hub.docker.com/r/paveloom/dev"

# Specify new user
ENV USER=paveloom

# Set HOME for this user
ENV HOME /home/$USER

# Temporarily copy scripts to the root
COPY scripts /scripts

# Allow their execution and let user own them
RUN chmod -R +x /scripts

# Set up a new user
RUN /scripts/root/basics/set-up-new-user.sh
# Temporarily disable prompts during the build
ARG DEBIAN_FRONTEND=noninteractive

# Set a time zone for tzdata
ENV TZ=Europe/Moscow

# Install essential packages
RUN /scripts/root/basics/install-essential-packages.sh
RUN /scripts/root/essential-packages/install-essential-packages.sh

# Specify new user
ENV USER=paveloom

# Set HOME for this user
ENV HOME /home/$USER

# Set up a new user
RUN /scripts/root/user/set-up-new-user.sh

# Install Zsh
RUN /scripts/root/zsh/install-zsh.sh

# Set SHELL to Zsh
ENV SHELL /bin/zsh

# Install docker
# Install Python
RUN /scripts/root/python/install-python.sh

# Temporarily disable apt-key warnings
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1

# Install Docker
RUN /scripts/root/docker/install-docker.sh

# Install python3
RUN /scripts/root/python3/install-python3.sh
# Install Node.js and npm
RUN /scripts/root/nodejs-and-npm/install-nodejs-and-npm.sh

# Install TexLive
RUN /scripts/root/texlive/install-texlive.sh

# Switch to the created user
USER $USER
Expand All @@ -53,6 +68,9 @@ RUN /scripts/user/ohmyzsh/install-ohmyzsh.sh
# Add ~/.local/bin to the PATH
ENV PATH=$PATH:/home/$USER/.local/bin

# Install Python packages
RUN /scripts/user/python/install-python-packages.sh

# Install JupyterLab
RUN /scripts/user/jupyterlab/install-jupyterlab.sh

Expand All @@ -63,4 +81,7 @@ ENV PATH=$PATH:/home/$USER/Other/julia/bin
RUN /scripts/user/julia/install-julia.sh

# Remove scripts
RUN sudo rm -rf /scripts
RUN sudo rm -rf /scripts

# Set DEBIAN_FRONTEND to teletype
ENV DEBIAN_FRONTEND=teletype
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
# Build an image squashing all layers, dive into it, delete redundant layers
build :
dive build -t image --squash .
docker images -q | grep -E -v "$$(docker images -q 'image')|$$(docker images -q 'alpine')" | xargs docker rmi
docker images -q | grep -E -v "$$(docker images -q 'image')|$$(docker images -q 'ubuntu')" | xargs docker rmi

## Run a container
run :
Expand All @@ -99,16 +99,21 @@
docker start container >/dev/null
docker exec -it container zsh

## Enter the container as root
in-root :
docker start container >/dev/null
docker exec -it -u root container zsh

## Show all Docker images
images :
docker images -a

## Show all Docker containers
ps :
docker ps -a
docker ps -as

## Stop and delete the container, delete all created images
reset :
docker stop container
docker rm container
docker images -q | grep -v "$$(docker images -q 'alpine')" | xargs docker rmi
docker images -q | grep -v "$$(docker images -q 'ubuntu')" | xargs docker rmi
76 changes: 54 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,49 @@ If you are not sure, please, follow only the instructions linked to [the last ta
### Contents

- Image version: 0.3.0
- Base image: alpine (3.12.0)
- Base image: Ubuntu (20.04)
- Essential packages:
- bash (5.0.17-r0)
- sudo (1.9.0-r0)
- git (2.26.2-r0)
- nano (4.9.3-r0)
- nano-syntax (4.9.3-r0)
- openssh (8.3_p1-r0)
- shadow (4.8.1-r0)
- User (paveloom) set-up
- Zsh (5.8-r1) as default shell
- Docker (19.03.11-r0)
- apt-utils
- apt-transport-https
- ca-certificates
- git
- nano
- wget
- curl
- gnupg-agent
- sudo (1.9.1)
- openssh-client
- software-properties-common
- Non-root user set-up
- Zsh as the default shell:
- [OhMyZsh](https://github.com/ohmyzsh/ohmyzsh):
- Additional plugins:
- [Zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
- [Theme adjustments](#color-theme)
- Docker
- Python:
- py3-pyzmq (18.1.1-r0)
- py3-pip (20.1.1-r0)
- wheel (0.34.2)
- python3-dev
- python3-pip
- Packages:
- wheel
- numpy
- matplotlib
- Jupyter:
- jupyter (1.0.0)
- jupyterlab (2.1.5)
- jupyter
- jupyterlab
- [Aliases to run a notebook server](#jupyter)
- Julia (1.5.0-rc1):
- [Revise.jl](https://github.com/timholy/Revise.jl) (precompiled)
- [OhMyZsh](https://github.com/ohmyzsh/ohmyzsh):
- Additional plugins:
- [Zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
- [Theme adjustments](#color-theme)
- Julia (1.4.2):
- [Revise.jl](https://github.com/timholy/Revise.jl)
- [IJulia.jl](https://github.com/JuliaLang/IJulia.jl/)
- [PyPlot.jl](https://github.com/JuliaPy/PyPlot.jl)
- [Plots.jl](https://github.com/JuliaPlots/Plots.jl)
- Node.js and npm
- TexLive:
- dvipng
- texlive-latex-extra
- texlive-fonts-extra
- texlive-lang-cyrillic
- cm-super

### Download

Expand Down Expand Up @@ -116,11 +133,25 @@ There are convenient aliases for the last step: `jnote` for Jupyter Notebook and

There is a ZenHub board, so make sure you have installed the extension to see in which pipelines the issues are.

### Key bindings

This image contains key bindings for deleting words before and after the cursor: <kbd>Ctrl+Backspace</kbd> and <kbd>Ctrl+Delete</kbd> respectively. However, if you are using Windows Terminal, you may find out that the first one doesn't work when using SSH. This has been discussed [here](https://github.com/microsoft/terminal/issues/755), and one of the solutions that you may use is this [AutoHotkey](https://www.autohotkey.com/) script:

```autohotkey
; For Windows Terminal: deletes the previous word
#IfWinActive ahk_exe WindowsTerminal.exe ; Only apply when this window is active
^backspace::
Send, ^H
return
#IfWinActive ; Turn off context sensitivity
```

### Color theme

Different terminals (like Xterm), programs (like Visual Studio Code) and utilities (like PuTTY) have their own color pallettes. So current theme may look ugly depending on what you use to enter the container. Since it's my image, I made it look more or less attractive when using [Windows Terminal](https://github.com/microsoft/terminal) with the following scheme:

```json
{
"name": "paveloom-theme",
"black": "#fefefe",
"red": "#f97e72",
Expand All @@ -140,6 +171,7 @@ Different terminals (like Xterm), programs (like Visual Studio Code) and utiliti
"brightWhite": "#fefefe",
"background": "#2a2139",
"foreground": "#f0eff1"
}
```

This one is based on [synthwave-everything](https://atomcorp.github.io/themes/?theme=synthwave-everything), which, I guess, was supposed to be used for local development. I made some changes to make it usable for remote development. So, with this being set up correctly, it should be looking something like this:
Expand Down
28 changes: 0 additions & 28 deletions scripts/root/basics/install-essential-packages.sh

This file was deleted.

24 changes: 0 additions & 24 deletions scripts/root/basics/set-up-new-user.sh

This file was deleted.

28 changes: 22 additions & 6 deletions scripts/root/docker/install-docker.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
#!/bin/sh

# Print info
echo -e '\n\e[1m\033[36mInstalling docker:\033[0m'
echo '\n\e[1m\033[36mInstalling docker:\033[0m'

# Install the package
echo -e '\e[1m\033[36m> Installing the package...\033[0m'
apk add --no-cache docker=19.03.11-r0 >/dev/null
# Update lists of packages
echo '\e[1m\033[36m> Updating lists of packages...\033[0m'
apt-get update >/dev/null

# Add docker's official GPG key
echo "\e[1m\033[36m> Addding docker's official GPG key...\033[0m"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - >/dev/null

# Set up stable repository
echo '\e[1m\033[36m> Setting up stable repository...\033[0m'
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" >/dev/null

# Install Docker engine
echo '\e[1m\033[36m> Installing Docker engine...\033[0m'
apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io >/dev/null

# Add the user to the docker group
echo -e '\e[1m\033[36m> Adding the user to the docker group...\033[0m\n'
sudo usermod -aG docker $USER
echo '\e[1m\033[36m> Adding the user to the docker group...\033[0m'
usermod -aG docker $USER

# Clean the apt cache
echo '\e[1m\033[36m> Cleaning the apt cache...\033[0m\n'
rm -rf /var/lib/apt/lists/*
Loading

0 comments on commit 904e918

Please sign in to comment.