Skip to content

Commit

Permalink
add ssh config and container script
Browse files Browse the repository at this point in the history
  • Loading branch information
shyanukant committed Oct 5, 2023
1 parent 29dc246 commit 96f26ad
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of your Django application code
COPY . .

# Start your Django application as usual
EXPOSE 8000
COPY sshd_config /etc/ssh/

CMD ["gunicorn", "squib.wsgi:application", "--workers=4", "--bind", "0.0.0.0:8000"]
# Start and enable SSH
RUN apt-get update \
&& apt-get install -y --no-install-recommends dialog \
&& apt-get install -y --no-install-recommends openssh-server \
&& echo "root:Docker!" | chpasswd \
&& chmod u+x /app/init_container.sh

EXPOSE 8000 2222

ENTRYPOINT [ "init_container.sh" ]
11 changes: 11 additions & 0 deletions init_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

# Get env vars in the Dockerfile to show up in the SSH session
eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile)

echo "Starting SSH ..."
service ssh start

# Start Gunicorn
CMD ["gunicorn", "squib.wsgi:application", "--workers=4", "--bind", "0.0.0.0:8000"]
12 changes: 12 additions & 0 deletions sshd_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Port 2222
ListenAddress 0.0.0.0
LoginGraceTime 180
X11Forwarding yes
Ciphers aes128-cbc,3des-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr
MACs hmac-sha1,hmac-sha1-96
StrictModes yes
SyslogFacility DAEMON
PasswordAuthentication yes
PermitEmptyPasswords no
PermitRootLogin yes
Subsystem sftp internal-sftp

0 comments on commit 96f26ad

Please sign in to comment.