From bc850e307934de43ba61cfa2606835db908a2de8 Mon Sep 17 00:00:00 2001 From: ellipticcurv3 <14904229+ellipticcurv3@users.noreply.github.com> Date: Mon, 20 Jan 2020 19:12:53 +0100 Subject: [PATCH 1/3] Added Dockerfile --- Dockerfile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Dockerfile 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"] From a7af8ccea9f7d6b23c4591843e4499ce9cfd8423 Mon Sep 17 00:00:00 2001 From: ellipticcurv3 <14904229+ellipticcurv3@users.noreply.github.com> Date: Mon, 20 Jan 2020 19:48:23 +0100 Subject: [PATCH 2/3] Added documentation for Docker --- README-Docker-Installation.md | 42 +++++++++++++++++++++++++++++++++++ README-Docker.md | 29 ++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 README-Docker-Installation.md create mode 100644 README-Docker.md 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..deb858d --- /dev/null +++ b/README-Docker.md @@ -0,0 +1,29 @@ +# Docker + +This repository contains a Dockerfile to run the Python SDK in Docker. + +## 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-sdk .` +- Create a new container and run the image within that container. + - **TEMPORARY CONTAINER** — `docker run --rm --name bunq-python-container -it bunq-python-sdk` will create and run a _temporary container_, i.e. it gets removed after it exits. + - **PERMANENT CONTAINER** — `docker run --name bunq-python-container -it bunq-python-sdk` 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-container` +- To remove the image: `docker image rm bunq-python-sdk` + +### Full removal + +- To remove dangling containers and images (dangerous, it removes all stopped containers and images from your system, including your own ones). + - `docker container prune` + - `docker image prune` + From ce6ddca4631e4057a8a34e4468fecfa8d9ac2e3a Mon Sep 17 00:00:00 2001 From: ellipticcurv3 <14904229+ellipticcurv3@users.noreply.github.com> Date: Tue, 21 Jan 2020 12:13:12 +0100 Subject: [PATCH 3/3] Updated Docker documentation --- README-Docker.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/README-Docker.md b/README-Docker.md index deb858d..6a51dd6 100644 --- a/README-Docker.md +++ b/README-Docker.md @@ -1,6 +1,6 @@ # Docker -This repository contains a Dockerfile to run the Python SDK in 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 @@ -10,20 +10,28 @@ This repository contains a Dockerfile to run the Python SDK in Docker. ## Usage - Once Docker is installed, clone this repository to a directory of choice. -- Build the image with `docker build -t bunq-python-sdk .` +- 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-container -it bunq-python-sdk` will create and run a _temporary container_, i.e. it gets removed after it exits. - - **PERMANENT CONTAINER** — `docker run --name bunq-python-container -it bunq-python-sdk` will create and run a _persistent container_, i.e. it remembers all changes and could be used for production. + - **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-container` -- To remove the image: `docker image rm bunq-python-sdk` +- To remove the container: `docker container rm bunq-python-tinker-container` +- To remove the image: `docker image rm bunq-python-tinker-image` -### Full removal +### Dangling containers and images -- To remove dangling containers and images (dangerous, it removes all stopped containers and images from your system, including your own ones). +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`