Skip to content
Snippets Groups Projects
Commit 748967d8 authored by fejao's avatar fejao
Browse files

Added docker

parent 430f7447
No related branches found
No related tags found
2 merge requests!2Adding files 01,!1Adding files 01
FROM python:3.10.15-bullseye
# Set variables
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ="Europe/Berlin"
# Install dependencies
RUN apt-get update -qq && apt-get upgrade -qqy \
&& apt-get install -qqy \
python3-pip \
htop \
vim \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create the folder at the container
WORKDIR /c3buttons
# Install python requirements
COPY ../../django/requirements.txt ./
RUN pip3 install -r requirements.txt
# Copy App
COPY ../../django/ .
### TEST
# CMD ["sleep", "10000000"]
### PROD
CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
---
services:
django:
image: c3buttons-django:latest
container_name: c3buttons-django
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/auth/test/open || exit 1"]
interval: 30s
timeout: 5s
retries: 5
### DISABLE PORTS FOR PRODUCTION
ports:
- '8000:8000'
# volumes:
# - ./django/data/db.sqlite3:/c3buttons/db.sqlite3
environment:
###
### PLEASE CHANGE THIS
###
- DEFAULT_TOKEN_REFRESH_DAYS=7
- DEFAULT_TOKEN_EXPIRE_MIN=10080 # 10080 min --> 7 days
- DEFAULT_DJANGO_DEBUG=true
gpio:
image: c3buttons-gpio:latest
container_name: c3buttons-gpio
restart: unless-stopped
#########
# healthcheck:
# test: ["CMD-SHELL", "curl -f http://localhost:8000/auth/test/open || exit 1"]
# interval: 30s
# timeout: 5s
# retries: 5
#########
# depends_on:
# django:
# condition: service_healthy
links:
- django
privileged: true
devices:
- /dev/gpiomem:/dev/gpiomem
volumes:
# - /dev/gpiomem:/dev/gpiomem
### DEBUG
- ../gpio_buttons:/c3buttons
environment:
###
### PLEASE CHANGE THIS
###
- 'DATABASE_API_TOKEN=<PLEASE_CHANGE_THIS>'
- 'BOXES_USED="BUTTON_BOX_1, BUTTON_BOX_2, BUTTON_BOX_3"'
# - 'BOXES_USED="BUTTON_BOX_1, BUTTON_BOX_2"'
- 'BUTTON_BOX_1={"pin_button": 16, "pin_led": 14}'
- 'BUTTON_BOX_2={"pin_button": 20, "pin_led": 19}'
- 'BUTTON_BOX_3={"pin_button": 21, "pin_led": 13}'
grafana:
image: grafana/grafana:latest
container_name: c3buttons-grafana
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000/api/health || exit 1"]
interval: 30s
timeout: 5s
retries: 5
# depends_on:
# django:
# condition: service_healthy
links:
- django
### DISABLE PORTS FOR PRODUCTION
ports:
- '3000:3000'
volumes:
- ./grafana/data:/var/lib/grafana
environment:
- FOO=BAR
- GF_FEATURE_TOGGLES_PUBLICDASHBOARDS=true
- TLS_SKIP_VERIFY_INSECURE=true
proxy:
image: 'jc21/nginx-proxy-manager:latest'
container_name: c3buttons-proxy
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:81 || exit 1"]
interval: 30s
timeout: 5s
retries: 5
# depends_on:
# django:
# condition: service_healthy
# grafana:
# condition: service_healthy
links:
- django
- grafana
ports:
- '80:80'
- '443:443'
### This is the admin port, disable for Production
- '81:81'
volumes:
- ./proxy/data:/data
- ./proxy/letsencrypt:/etc/letsencrypt
FROM ubuntu:24.04
# Set variables
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ="Europe/Berlin"
# Install dependencies
RUN apt-get update -qq && apt-get upgrade -qqy \
# python3-dev \
# python3-venv \
&& apt-get install -qqy \
python3-pip \
python3-lgpio \
python3-pigpio \
python3-rpi.gpio \
htop \
vim \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# New debian base FUCKING shit
RUN rm -rfv /usr/lib/python3*/EXTERNALLY-MANAGED
# Change user for installing python packages -> Set user and group
ARG user=appuser
ARG group=appuser
ARG uid=2000
ARG gid=2000
RUN groupadd -g ${gid} ${group}
# <--- the '-m' create a user home directory
RUN useradd -u ${uid} -g ${group} -s /bin/sh -m ${user}
# Create the folder at the container
WORKDIR /home/appuser/c3buttons
# Install python requirements
COPY ../../gpio_buttons/requirements.txt ./
RUN pip3 install -r requirements.txt
# Install GPIO
RUN pip3 install gpiozero --break-system-packages
# Copy App
COPY ../../gpio_buttons/ .
### TEST
CMD ["sleep", "1000000"]
### PROD
# CMD ["python3", "main.py"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment