-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (30 loc) · 1.01 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Use a lightweight base image with Python
FROM python:3.9-slim
# Install gnupg and other required packages
RUN apt-get update && apt-get install -y \
gnupg \
gcc \
python3-dev \
sudo \
util-linux \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Add the Raspberry Pi OS repository to sources.list
RUN echo "deb http://archive.raspberrypi.org/debian/ buster main" > /etc/apt/sources.list.d/raspi.list
# Add the Raspberry Pi OS public key
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 82B129927FA3303E
# Install raspi-gpio
RUN apt-get update && apt-get install -y \
raspi-gpio \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install RPi.GPIO using pip
RUN python3 -m pip install RPi.GPIO
# Copy the Python script into the container
COPY mcu_shutdown.py /usr/src/app/mcu_shutdown.py
# Set the working directory
WORKDIR /usr/src/app
# Set environment variables if needed
ENV LOW_DURATION_THRESHOLD=10
# Run the Python script
CMD ["python3", "mcu_shutdown.py"]