-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
31 lines (24 loc) · 1.02 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
FROM python:3.12.5-alpine
# Install necessary packages and configure SSH
RUN apk update && \
apk add --no-cache openssh nano dhclient gcc musl-dev libffi-dev tzdata openrc && \
sed -i -e 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' \
-e 's/^#PasswordAuthentication.*/PasswordAuthentication yes/' \
/etc/ssh/sshd_config && \
ssh-keygen -A && \
rc-status && \
touch /run/openrc/softlevel && \
rc-update add sshd default
# Set the time zone
ENV TZ=Europe/Amsterdam
# Set the working directory in the container
WORKDIR /app
# Copy only requirements first to leverage Docker cache
COPY requirements.txt .
COPY dhclient.conf /etc/dhcp/dhclient.conf
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the application files to the container
COPY . .
# Start OpenRC and SSH, then run the Python script
CMD ["/bin/sh", "-c", "echo \"root:$SSH_PASSWORD\" | chpasswd && rc-service sshd start && dhclient -v eth0 && python tibber_energy_monitor.py"]