Update frank to latest arq. We are having issues with duplicate kots being printed. This might be because the server arq is updated.

Also added the frank service and build frank script to the frank playbook so that new containers can be built on the device when ansible is not an option
This commit is contained in:
Amritanshu Agrawal 2021-06-23 09:41:56 +05:30
parent 40aced4fa3
commit 8a243fe387
6 changed files with 53 additions and 8 deletions

View File

@ -4,7 +4,7 @@ WORKDIR /app
ADD https://git.tanshu.com/tanshu/barker/raw/branch/main/frank/pyproject.toml /app/pyproject.toml
# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false && \

1
docker/files/build-frank.sh Executable file
View File

@ -0,0 +1 @@
docker build --file /home/pi/dockerfile/app/frank.Dockerfile --tag frank:latest /home/pi/dockerfile/app

View File

@ -0,0 +1,13 @@
[Unit]
Description=Frank container service
After=docker.service knox-redis-tunnel.service
Wants=network-online.target docker.socket knox-redis-tunnel.service
Requires=docker.socket knox-redis-tunnel.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a frank
ExecStop=/usr/bin/docker stop -t 10 frank
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1 @@
docker run --detach --name frank --hostname=moh1 --env-file=/home/pi/frank.env --network=host --restart=no --device /dev/usb/lp0:/printer frank:latest

View File

@ -9,19 +9,27 @@
tasks:
- name: Copy dockerfile
synchronize: src=app dest=/tmp
synchronize: src=app dest=/home/pi/dockerfile
- name: Build frank image
docker_image:
name: frank:latest
build:
path: /tmp/app/
dockerfile: /tmp/app/frank.Dockerfile
path: /home/pi/dockerfile/app
dockerfile: /home/pi/dockerfile/app/frank.Dockerfile
pull: yes
state: present
source: build
- name: Upload the worker .env file
- name: Check if frank .env file exists
stat: path="/home/pi/frank.env"
register: status
- name: No need to upload the frank .env file
debug: msg= {{ "No need to upload the frank .env file as it already exists." }}
- name: Upload the frank .env file
when: status.stat.exists == false
template:
src: "files/frank.env"
dest: "/home/pi/frank.env"
@ -31,8 +39,30 @@
name: "frank"
image: frank:latest
state: started
restart_policy: "unless-stopped"
restart_policy: "no"
env_file: "/home/pi/frank.env"
network_mode: "host"
devices:
- "{{ printer_port }}:/printer"
- name: Copy docker build script
synchronize: src=files/build-frank.sh dest=/home/pi/dockerfile/build-frank.sh
- name: Copy docker run script
synchronize: src=files/frank.sh dest=/home/pi/dockerfile/frank.sh
- name: install frank systemd unit file
template:
src: "files/frank.service"
dest: "/etc/systemd/system/frank.service"
- name: enable service frank and ensure it is not masked
systemd:
name: frank
enabled: yes
masked: no
- name: Make sure frank service is running
systemd:
state: started
name: frank

View File

@ -6,8 +6,8 @@ authors = ["tanshu <git@tanshu.com>"]
[tool.poetry.dependencies]
python = "^3.8"
pydantic = {extras = ["dotenv"], version = "^1.8.1"}
arq = "^0.19.1"
pydantic = {extras = ["dotenv"], version = "^1.8.2"}
arq = "^0.20"
aiohttp = "^3.7.4"
[build-system]