Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker: various issues using SIP #338

Closed
ctosae opened this issue Jun 7, 2024 · 1 comment
Closed

Docker: various issues using SIP #338

ctosae opened this issue Jun 7, 2024 · 1 comment

Comments

@ctosae
Copy link

ctosae commented Jun 7, 2024

I'm running SIP in a Docker with this issues:

Nowadays I think it's essential to be able to run Dockers
I provide everything to create one, can someone help me?

TIMEZONE

ln -sf /usr/share/zoneinfo/Europe/Rome /etc/localtime
echo "Europe/Rome" > /etc/timezone
systemctl restart systemd-timedated
# Check
timedatectl status

DOCKER SETUP

# Install Docker
apt install docker.io
systemctl enable docker

# Install docker-compose
curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

DOCKER BUILD

  • Dockerfile
FROM ubuntu:22.04

# Install required packages
RUN apt-get -y update && apt-get -y install git python3 curl python3-pip

# Create a directory for the application
WORKDIR /SIP

# Copy the requirements.txt file
COPY requirements.txt /SIP/requirements.txt

# Install Python dependencies
RUN pip3 install --no-cache-dir -r /SIP/requirements.txt

# Copy the initialization script
COPY init.sh /init.sh
RUN chmod +x /init.sh

# Command to run the application
CMD ["/init.sh"]
  • compose.yml
version: "3"
services:
  sip-irrigation:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: sip-irrigation
    network_mode: host
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - "./SIP:/SIP"
  • init.sh
#!/bin/sh

# Clone the SIP repository if the directory is empty
if [ -z "$(ls -A /SIP)" ]; then
  git clone https://github.com/Dan-in-CA/SIP /SIP
fi

# Run the application
exec python3 -u /SIP/sip.py
  • requirements.txt
urllib3
six
#RPI.GPIO
#pigpio

And then:
docker-compose up --build

Building sip-irrigation
[+] Building 0.1s (12/12) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                    0.0s
 => => transferring dockerfile: 509B                                                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                                                       0.0s
 => => transferring context: 2B                                                                                                                                                                         0.0s
 => [internal] load metadata for docker.io/library/ubuntu:22.04                                                                                                                                         0.0s
 => [1/7] FROM docker.io/library/ubuntu:22.04                                                                                                                                                           0.0s
 => [internal] load build context                                                                                                                                                                       0.0s
 => => transferring context: 64B                                                                                                                                                                        0.0s
 => CACHED [2/7] RUN apt-get -y update && apt-get -y install git python3 curl python3-pip                                                                                                               0.0s
 => CACHED [3/7] WORKDIR /SIP                                                                                                                                                                           0.0s
 => CACHED [4/7] COPY requirements.txt /SIP/requirements.txt                                                                                                                                            0.0s
 => CACHED [5/7] RUN pip3 install --no-cache-dir -r /SIP/requirements.txt                                                                                                                               0.0s
 => CACHED [6/7] COPY init.sh /init.sh                                                                                                                                                                  0.0s
 => CACHED [7/7] RUN chmod +x /init.sh                                                                                                                                                                  0.0s
 => exporting to image                                                                                                                                                                                  0.0s
 => => exporting layers                                                                                                                                                                                 0.0s
 => => writing image sha256:1bb34db93f60ab5c4d1e4e4998df3d7f7005e4221d1df5245a5731d8a9614cd1                                                                                                            0.0s
 => => naming to docker.io/library/docker_sip-irrigation:latest                                                                                                                                         0.0s
Starting sip-irrigation ... done
Attaching to sip-irrigation
sip-irrigation    | Cloning into '/SIP'...
sip-irrigation    | WARNING: No GPIO library was loaded,
sip-irrigation    | SIP will run but stations will NOT be activated.
sip-irrigation    | Please be sure either RPI.GPIO or pigpio for Python (or both) is installed.
sip-irrigation    | error importing GPIO pins into helpers
sip-irrigation    | Ignoring exception while loading the plugin_manager plug-in.
sip-irrigation    | No module named 'charset_normalizer'
sip-irrigation    | plugins loaded:
sip-irrigation    |   mobile_app
sip-irrigation    |   system_update
sip-irrigation    | Starting timing loop
sip-irrigation    |
sip-irrigation    | http://:::80/

Running....
Thanks!

@ctosae
Copy link
Author

ctosae commented Jul 29, 2024

I continue to report the 2 issues separately

@ctosae ctosae closed this as completed Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant