From f43c94c6262678931b2a0c7d322e22ee61c6d5d3 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sun, 10 Nov 2019 17:18:53 +0100 Subject: [PATCH] Fix debug build --- README.md | 16 +++++++++------- ansible.yml | 3 +-- src/Dockerfile | 7 ++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b88ba8e..5ff09be 100644 --- a/README.md +++ b/README.md @@ -9,20 +9,22 @@ You can check it out here: https://impenetrable.fortress.promo/communistquotes Edit the file [communistquotes/marxistquotes.csv](communistquotes/marxistquotes.csv) and make an MR. -## Compile and Run +## Compile and Debug -First, copy `env.example` to `env`, then enter your actual login information. To run the bot, +To run the bot, execute the following commands: ```bash -cd communistquotes/templates/ -sudo docker build . -t communistquotes -sudo docker run -it --rm --name communistquotes --env-file ../env communistquotes --debug +$ cd communistquotes/ +$ sudo docker build . -f src/Dockerfile -t communistquotes +$ sudo docker run -it --rm --name communistquotes communistquotes --debug ``` ## Deploy -Copy `inventory.example` to `inventory`, and enter your server's ssh address. Then run the following command: +You need a Mastodon/Pleroma account where the bot will post, and ssh access to a server where the Python bot will run. This can both running on the same server, or they can be seperate. + +First, copy `env.example` to `env`, then enter the login information for your Mastodon/Pleroma bot account. Copy `inventory.example` to `inventory`, and enter your server's ssh address. Then run the following command: ``` -ansible-playbook ansible.yml --become +$ ansible-playbook ansible.yml --become ``` \ No newline at end of file diff --git a/ansible.yml b/ansible.yml index b77f0c9..2c62d0d 100644 --- a/ansible.yml +++ b/ansible.yml @@ -20,8 +20,7 @@ - name: copy all build files recursively copy: src={{ item.from }} dest={{ item.to }} with_items: - # folder structure on the target server is intentionally different - - { from: 'src/', to: '/tmp/communistquotes' } + - { from: 'src/', to: '/tmp/communistquotes/src' } - { from: 'quotes/', to: '/tmp/communistquotes/quotes' } - name: Build image using cache source diff --git a/src/Dockerfile b/src/Dockerfile index e8e5281..166f23d 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -2,9 +2,10 @@ FROM python:3-alpine WORKDIR /usr/src/app -COPY requirements.txt ./ +COPY src/requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt -COPY . . +COPY src/*.py src/ +COPY quotes/ quotes/ -ENTRYPOINT [ "python", "./main.py" ] +ENTRYPOINT [ "python", "./src/main.py" ]