-
Notifications
You must be signed in to change notification settings - Fork 25
/
Dockerfile.debug
102 lines (85 loc) · 2.7 KB
/
Dockerfile.debug
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# ARGUMENTS --------------------------------------------------------------------
##
# Board architecture
##
ARG IMAGE_ARCH=
##
# Base container version
##
ARG BASE_VERSION=3.3.1-bookworm
##
# Debug port
##
ARG DEBUG_SSH_PORT=
##
# Run as
##
ARG SSHUSERNAME=
##
# Directory of the application inside container
##
ARG APP_ROOT=
FROM --platform=linux/${IMAGE_ARCH} \
commontorizon/debian:${BASE_VERSION} AS debug
ARG IMAGE_ARCH
ARG DEBUG_SSH_PORT
ARG SSHUSERNAME
ARG APP_ROOT
# SSH for remote debug
EXPOSE ${DEBUG_SSH_PORT}
EXPOSE 6512
# Make sure we don't get notifications we can't answer during building.
ENV DEBIAN_FRONTEND="noninteractive"
# your regular RUN statements here
# Install required packages
RUN apt-get -q -y update && \
apt-get -q -y install \
openssl \
openssh-server \
rsync \
file \
screen \
python3-minimal \
python3-pip \
python3-setuptools \
python3-venv \
&& apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
# automate for torizonPackages.json
RUN apt-get -q -y update && \
apt-get -q -y install \
# DO NOT REMOVE THIS LABEL: this is used for VS Code automation
# __torizon_packages_dev_start__
# __torizon_packages_dev_end__
# DO NOT REMOVE THIS LABEL: this is used for VS Code automation
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
# Create virtualenv
RUN python3 -m venv ${APP_ROOT}/.venv --system-site-packages
# Install pip packages on venv
COPY requirements-debug.txt /requirements-debug.txt
RUN . ${APP_ROOT}/.venv/bin/activate && \
pip3 install --upgrade pip && pip3 install -r requirements-debug.txt && \
rm requirements-debug.txt && \
chown -R ${SSHUSERNAME}:${SSHUSERNAME} ${APP_ROOT}
# ⚠️ DEBUG PURPOSES ONLY!!
# THIS CONFIGURES AN INSECURE SSH CONNECTION
# create folders needed for the different components
# configures SSH access to the container and sets environment by default
RUN mkdir /var/run/sshd && \
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' \
-i /etc/pam.d/sshd && \
if test $SSHUSERNAME != root ; \
then mkdir -p /home/$SSHUSERNAME/.ssh ; \
else mkdir -p /root/.ssh ; fi && \
echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config && \
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config && \
echo "Port ${DEBUG_SSH_PORT}" >> /etc/ssh/sshd_config && \
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && \
echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config && \
su -c "env" $SSHUSERNAME > /etc/environment && \
echo "$SSHUSERNAME:" | chpasswd -e
RUN rm -r /etc/ssh/ssh*key && \
dpkg-reconfigure openssh-server
CMD [ "/usr/sbin/sshd", "-D" ]