Skip to content

Added Dockerfile #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from ubuntu:bionic

# Install the dependencies
RUN apt update && \
apt install -y curl \
git \
python3 \
python-pip \
python3-distutils \
qrencode \
jq \
locales

# Set the locale
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Install pipenv
RUN pip install pipenv

# Set up user and home directories
SHELL ["/bin/bash", "-c"]
RUN useradd -s /bin/bash bunq
RUN mkdir -p /home/bunq && chown -R bunq: /home/bunq

USER bunq
WORKDIR /home/bunq
COPY --chown=bunq:bunq . .

# Remove -W ignore
RUN sed -i -e 's/ -W ignore//' ./tinker/**/*.py

# Remove Empty Directory assert
RUN sed -i -e 's/^assertIsRanInEmptyDirectory$//' ./setup.sh

# Remove Git clone
RUN sed -i -e 's/^cloneTinkerPython$//' ./setup.sh

# Run the setup script
RUN ["/bin/bash", "-c", "bash ./setup.sh"]

CMD ["/bin/bash"]
42 changes: 42 additions & 0 deletions README-Docker-Installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Docker Installation Guide

This guide explains how to install Docker on your host system.

## Ubuntu

First thing you'll need to do is to install Docker

````sh
sudo apt install docker.io
````

Then, add your current user to the `docker` group

```sh
sudo gpasswd -a $USER docker && newgrp docker
```

After that, try to run the `hello-world` docker-image to test if all permissions are set up correctly and your Docker installation works

````sh
docker run hello-world
````

Docker should begin downloading the `hello-world` image and run it immediately, and shows the following output:

```
Hello from Docker!
This message shows that your installation appears to be working correctly.

(...)
```

Done.

## macOS

- To do.

## Windows

- To do.
37 changes: 37 additions & 0 deletions README-Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Docker

This repository contains a Dockerfile to run the Python-based Bunq tinker code in Docker. This file can be used to create a Docker image from this repository and run the code within a Docker container. The main benefit is that the results are reproducible, this reduces the time needed to hunt for bugs.

## Prerequisites

- You should have Docker installed on your host system.
- Instructions to install Docker can be found [here](./README-Docker-Installation.md).

## Usage

- Once Docker is installed, clone this repository to a directory of choice.
- Build the image with `docker build -t bunq-python-tinker-image .`
- Create a new container and run the image within that container.
- **TEMPORARY CONTAINER** — `docker run --rm --name bunq-python-tinker-container -it bunq-python-tinker-image` will create and run a _temporary container_, i.e. it gets removed after it exits.
- **PERMANENT CONTAINER** — `docker run --name bunq-python-tinker-container -it bunq-python-tinker-image` will create and run a _persistent container_, i.e. it remembers all changes and could be used for production.
- Try to run `tinker/user_overview.py`. It will automatically create a new sandbox account.

## Removal

- To remove the container: `docker container rm bunq-python-tinker-container`
- To remove the image: `docker image rm bunq-python-tinker-image`

### Dangling containers and images

Sometimes during development you choose to create multiple containers using different names. That's very useful when tinkering, but could also result in having containers you didn't know you still had.

- To list all containers and images
- `docker container ls --all`
- `docker image ls --all`
- To remove a particular container or image
- `docker container rm <CONTAINER ID>`
- `docker image rm <IMAGE ID>`
- To remove dangling containers and images (dangerous, it removes all stopped containers and unused images from your system, including your own ones).
- `docker container prune`
- `docker image prune`