Moved printing into its own separate project called frank. It also has its own toml and deployement system.
It also works on a raspberry pi
This commit is contained in:
24
docker/app/frank.Dockerfile
Normal file
24
docker/app/frank.Dockerfile
Normal file
@ -0,0 +1,24 @@
|
||||
FROM python:latest
|
||||
RUN mkdir /app
|
||||
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 && \
|
||||
cd /usr/local/bin && \
|
||||
ln -s /opt/poetry/bin/poetry && \
|
||||
poetry config virtualenvs.create false && \
|
||||
cd /app && \
|
||||
poetry install --no-root --no-dev
|
||||
|
||||
ADD https://git.tanshu.com/api/v1/repos/tanshu/barker/tags /tags.json
|
||||
RUN git clone --single-branch --depth 1 https://git.tanshu.com/tanshu/barker.git /repo
|
||||
RUN mv /repo/frank/* /app
|
||||
|
||||
ENV PYTHONPATH=/app
|
||||
|
||||
RUN chmod 777 /app/worker-start.sh \
|
||||
&& ln -s /app/worker-start.sh /usr/local/bin/worker-start.sh \
|
||||
&& ln -s /app/worker-start.sh /
|
||||
|
||||
CMD ["bash", "worker-start.sh"]
|
||||
@ -1,8 +0,0 @@
|
||||
FROM barker:latest
|
||||
LABEL maintainer="Amritanshu <docker@tanshu.com>"
|
||||
|
||||
RUN chmod 777 /app/worker-start.sh \
|
||||
&& ln -s /app/worker-start.sh /usr/local/bin/worker-start.sh \
|
||||
&& ln -s /app/worker-start.sh /
|
||||
|
||||
CMD ["bash", "worker-start.sh"]
|
||||
@ -1,3 +0,0 @@
|
||||
WORKER_REDIS_HOST=redis
|
||||
WORKER_REDIS_PORT=6379
|
||||
WORKER_QUEUE_NAME="DJ Computer"
|
||||
3
docker/files/frank.env
Normal file
3
docker/files/frank.env
Normal file
@ -0,0 +1,3 @@
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
QUEUE_NAME=DJ Computer
|
||||
@ -1,3 +0,0 @@
|
||||
WORKER_REDIS_HOST=redis
|
||||
WORKER_REDIS_PORT=6379
|
||||
WORKER_QUEUE_NAME="Ground Floor Printer"
|
||||
@ -21,26 +21,11 @@
|
||||
state: present
|
||||
source: build
|
||||
|
||||
- name: Build barker worker image
|
||||
docker_image:
|
||||
name: barker-worker:latest
|
||||
build:
|
||||
path: /tmp/app/
|
||||
dockerfile: /tmp/app/worker.Dockerfile
|
||||
pull: yes
|
||||
state: present
|
||||
source: build
|
||||
|
||||
- name: Upload the .env file
|
||||
template:
|
||||
src: "files/chd.env"
|
||||
dest: "/var/lib/{{ host_directory }}/.env"
|
||||
|
||||
- name: Upload the worker .env file
|
||||
template:
|
||||
src: "files/chd-worker.env"
|
||||
dest: "/var/lib/{{ host_directory }}/worker.env"
|
||||
|
||||
- name: Create barker container
|
||||
docker_container:
|
||||
name: "{{ host_directory }}"
|
||||
@ -56,17 +41,6 @@
|
||||
volumes:
|
||||
- "/var/lib/{{ host_directory }}/frontend:/frontend"
|
||||
|
||||
- name: Create barker worker container
|
||||
docker_container:
|
||||
name: "{{ host_directory }}-worker"
|
||||
image: barker-worker:latest
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
env_file: "/var/lib/{{ host_directory }}/worker.env"
|
||||
links:
|
||||
- "redis:redis"
|
||||
|
||||
|
||||
- name: Check if Nginx conf file exists
|
||||
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
|
||||
register: status
|
||||
|
||||
38
docker/playbook-frank.yml
Executable file
38
docker/playbook-frank.yml
Executable file
@ -0,0 +1,38 @@
|
||||
#################################################
|
||||
# DO Community Playbooks: Docker
|
||||
#################################################
|
||||
---
|
||||
- hosts: all
|
||||
become: true
|
||||
vars_files:
|
||||
- vars/frank.yml
|
||||
|
||||
tasks:
|
||||
- name: Copy dockerfile
|
||||
synchronize: src=app dest=/tmp
|
||||
|
||||
- name: Build frank image
|
||||
docker_image:
|
||||
name: frank:latest
|
||||
build:
|
||||
path: /tmp/app/
|
||||
dockerfile: /tmp/app/frank.Dockerfile
|
||||
pull: yes
|
||||
state: present
|
||||
source: build
|
||||
|
||||
- name: Upload the worker .env file
|
||||
template:
|
||||
src: "files/frank.env"
|
||||
dest: "/home/pi/frank.env"
|
||||
|
||||
- name: Create frank worker container
|
||||
docker_container:
|
||||
name: "frank"
|
||||
image: frank:latest
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
env_file: "/home/pi/frank.env"
|
||||
network_mode: "host"
|
||||
devices:
|
||||
- "{{ printer_port }}:/printer"
|
||||
@ -21,26 +21,11 @@
|
||||
state: present
|
||||
source: build
|
||||
|
||||
- name: Build barker worker image
|
||||
docker_image:
|
||||
name: barker-worker:latest
|
||||
build:
|
||||
path: /tmp/app/
|
||||
dockerfile: /tmp/app/worker.Dockerfile
|
||||
pull: yes
|
||||
state: present
|
||||
source: build
|
||||
|
||||
- name: Upload the .env file
|
||||
template:
|
||||
src: "files/pkl.env"
|
||||
dest: "/var/lib/{{ host_directory }}/.env"
|
||||
|
||||
- name: Upload the worker .env file
|
||||
template:
|
||||
src: "files/pkl-worker.env"
|
||||
dest: "/var/lib/{{ host_directory }}/worker.env"
|
||||
|
||||
- name: Create barker container
|
||||
docker_container:
|
||||
name: "{{ host_directory }}"
|
||||
@ -56,17 +41,6 @@
|
||||
volumes:
|
||||
- "/var/lib/{{ host_directory }}/frontend:/frontend"
|
||||
|
||||
- name: Create barker worker container
|
||||
docker_container:
|
||||
name: "{{ host_directory }}-worker"
|
||||
image: barker-worker:latest
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
env_file: "/var/lib/{{ host_directory }}/worker.env"
|
||||
links:
|
||||
- "redis:redis"
|
||||
|
||||
|
||||
- name: Check if Nginx conf file exists
|
||||
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
|
||||
register: status
|
||||
|
||||
2
docker/vars/frank.yml
Normal file
2
docker/vars/frank.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
printer_port: "/dev/usb/lp0"
|
||||
Reference in New Issue
Block a user