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

Commit

Permalink
(#43) Add bash, Python, and JupyterLab.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Sobolev committed Jul 1, 2020
1 parent 8169cec commit 87ea011
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 15 deletions.
6 changes: 5 additions & 1 deletion .github/scripts/Build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ docker exec container docker version
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

# Stop the container
echo -e '\e[1m\033[36mStopping the container...\033[0m\n'
echo -e '\n\e[1m\033[36mStopping the container...\033[0m\n'
docker stop container
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ dist: bionic
os:
- linux

branches:
except:
- master

services:
- docker

Expand All @@ -14,11 +18,9 @@ jobs:
include:
- stage: "Build & Check"
name: "Build Docker Image"
if: branch != master
script: bash .github/scripts/Build.bash
- script: bash .github/scripts/VersionCheck.bash
name: "Check Version"
if: branch != master

notifications:
email: false
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ FROM alpine:3.12.0
# Meta information
LABEL maintainer="Pavel Sobolev (https://github.com/Paveloom)"
LABEL version="0.2.0"
LABEL description="This is paveloom's dev image."
LABEL description="This is an image containing paveloom's personal development environment."
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
Expand All @@ -30,11 +32,14 @@ RUN /scripts/root/basics/install-essential-packages.sh
# Install Zsh
RUN /scripts/root/zsh/install-zsh.sh

# Set SHELL to Zsh
ENV SHELL /bin/zsh

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

# Set SHELL to Zsh
ENV SHELL /bin/zsh
# Install python3
RUN /scripts/root/python3/install-python3.sh

# Switch to the created user
USER $USER
Expand All @@ -45,5 +50,11 @@ WORKDIR $HOME
# Install OhMyZsh
RUN /scripts/user/ohmyzsh/install-ohmyzsh.sh

# Add ~/.local/bin to the PATH
ENV PATH=$PATH:/home/$USER/.local/bin

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

# Remove scripts
RUN sudo rm -rf /scripts
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

## Run a container
run :
docker run -v /var/run/docker.sock:/var/run/docker.sock --name container -t -d image
docker run -p 8888:8888 -v /var/run/docker.sock:/var/run/docker.sock --name container -t -d image

## Enter the container
in :
Expand Down
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Description

### A notice

If you are not sure, please, follow [the instructions of the last released version](https://github.com/paveloom-d/dev/tree/9251bb9ba7cc404bf30149562e68c123de6bc667) only.

### Contents

- Image version: 0.2.0
- Base image: alpine (3.12.0)
- Basic packages:
- Essential packages:
- bash (5.0.17-r0)
- sudo (1.9.0-r0)
- git (2.26.2-r0)
- nano (4.9.3-r0)
Expand All @@ -12,10 +18,19 @@
- shadow (4.8.1-r0)
- User (paveloom) set-up
- Zsh (5.8-r1) as default shell
- Docker (19.03.11-r0)
- Python:
- py3-pyzmq (18.1.1-r0)
- py3-pip (20.1.1-r0)
- wheel (0.34.2)
- Jupyter:
- jupyter (1.0.0)
- jupyterlab (2.1.5)
- [Aliases to run a notebook server](#jupyter)
- [OhMyZsh](https://github.com/ohmyzsh/ohmyzsh):
- Additional plugins:
- [Zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
- Theme adjustments
- [Theme adjustments](#color-theme)

### Download

Expand All @@ -41,13 +56,13 @@ There is nothing specific when building, although I would recommend squashing th
}
```

To build the image in the root directory (where Dockerfile is located) run the following:
To build the image run the following in the root directory (where Dockerfile is located):

```bash
docker build -t image --squash .
```

If you want to develop docker containers inside the container, it is recommended to bind-mount Docker socket when running it, as follows:
If you want to develop docker containers inside the container, it is recommended to bind-mount Docker socket when running it as follows:

```bash
docker run -v /var/run/docker.sock:/var/run/docker.sock --name container -t -d image
Expand All @@ -61,7 +76,7 @@ sudo chmod o+rw /var/run/docker.sock

If you don't need this functionality, you can omit the `-v` flag above.

Since Zsh is the default shell, enter the container using the following command:
Since Zsh is the default shell, you can enter the container using the following command:

```bash
docker exec -it container zsh
Expand All @@ -75,7 +90,25 @@ make run
make in
```

Build rule will call [dive](https://github.com/wagoodman/dive), so be sure you have this tool, or just change `dive` to `build` inside Makefile. Be mindful though that the build rule here will delete all other images except mine and Alpine's.
The build rule will call [dive](https://github.com/wagoodman/dive), so be sure you have this tool, or just change `dive` to `docker` inside the Makefile. Be mindful though that the build rule here will delete all other images except mine and Alpine's.

### Jupyter

To use Jupyter Notebook / Jupyter Lab you will need to do two things.

First, publish the `8888` port when running a container:

```bash
docker run -p 8888:8888 --name container -t -d image
```

Secondly, when in the container, make notebook server listen on `0.0.0.0`:

```bash
jupyter notebook --ip 0.0.0.0 --no-browser
```

There are convenient aliases for the last step: `jnote` for Jupyter Notebook and `jlab` for Jupyter Lab.

### Development

Expand Down Expand Up @@ -107,6 +140,6 @@ Different terminals (like Xterm), programs (like Visual Studio Code) and utiliti
"foreground": "#f0eff1"
```

This one is based on [synthwave-everything](https://atomcorp.github.io/themes/?theme=synthwave-everything), which, I believe, 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:
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:

![](https://github.com/paveloom-d/dev/raw/master/.github/pictures/colors.png)
4 changes: 4 additions & 0 deletions scripts/root/basics/install-essential-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# Print info
echo -e '\n\e[1m\033[36mInstalling essential packages:\033[0m'

# Install bash
echo -e '\e[1m\033[36m> Installing bash...\033[0m'
apk add --no-cache bash=5.0.17-r0 >/dev/null

# Install git
echo -e '\e[1m\033[36m> Installing git...\033[0m'
apk add --no-cache git=2.26.2-r0 >/dev/null
Expand Down
2 changes: 1 addition & 1 deletion scripts/root/docker/install-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ echo -e '\e[1m\033[36m> Installing the package...\033[0m'
apk add --no-cache docker=19.03.11-r0 >/dev/null

# Add the user to the docker group
echo -e '\e[1m\033[36m> Adding user to the docker group...\033[0m\n'
echo -e '\e[1m\033[36m> Adding the user to the docker group...\033[0m\n'
sudo usermod -aG docker $USER
12 changes: 12 additions & 0 deletions scripts/root/python3/install-python3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

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

# Install the package
echo -e '\e[1m\033[36m> Installing python3...\033[0m'
apk add --no-cache py3-pyzmq=18.1.1-r0 >/dev/null

# Install pip3
echo -e '\e[1m\033[36m> Installing pip3...\033[0m\n'
apk add --no-cache py3-pip=20.1.1-r0 >/dev/null
23 changes: 23 additions & 0 deletions scripts/user/jupyterlab/install-jupyterlab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

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

# Install wheel
echo -e '\e[1m\033[36m> Installing wheel...\033[0m'
pip3 install --no-cache-dir wheel==0.34.2 >/dev/null

# Install jupyter
echo -e '\e[1m\033[36m> Installing jupyter...\033[0m'
pip3 install --no-cache-dir jupyter==1.0.0 >/dev/null

# Install jupyterlab
echo -e '\e[1m\033[36m> Installing jupyterlab...\033[0m'
pip3 install --no-cache-dir jupyterlab==2.1.5 >/dev/null

# Add aliases for running a notebook server
echo -e '\e[1m\033[36m> Adding aliases for running a notebook server...\033[0m\n'
echo '
# Aliases for running a notebook server
alias jnote="jupyter notebook --ip 0.0.0.0 --no-browser"
alias jlab="jupyter lab --ip 0.0.0.0 --no-browser"' >> ~/.zshrc

0 comments on commit 87ea011

Please sign in to comment.