diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dcd8f5f --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/README-Docker-Installation.md b/README-Docker-Installation.md new file mode 100644 index 0000000..3f24a04 --- /dev/null +++ b/README-Docker-Installation.md @@ -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. \ No newline at end of file diff --git a/README-Docker.md b/README-Docker.md new file mode 100644 index 0000000..6a51dd6 --- /dev/null +++ b/README-Docker.md @@ -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 ` + - `docker image rm ` +- 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` +