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

Add ssh to local development image to allow dev ide to debug project in docker #1244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,28 @@ FROM base AS development
# additional package required otherwise build of coveralls fails
RUN apk add --no-cache libffi-dev

# Allow connecting to the container via ssh so that some IDE's can use the python interpreter
RUN apk add openssh vim
RUN ssh-keygen -A
# Create directory for SSHD to run
RUN mkdir /var/run/sshd
# Set a password for root (for testing purposes)
RUN echo 'root:password' | chpasswd
# Allow root login with password
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/AllowTcpForwarding\sno/AllowTcpForwarding yes/' /etc/ssh/sshd_config

# Expose SSH port
EXPOSE 22


RUN PIP_CONSTRAINT=/tmp/constraint.txt pip install -r ./requirements/requirements-dev.txt --no-cache-dir
COPY . .

# Make sure static assets directory has correct permissions
RUN chown -R app:app /home/app && \
mkdir -p cla_backend/assets

USER 1000
EXPOSE 8000
CMD ["docker/run_dev.sh"]

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
target: ${ENVIRONMENT:-development}
ports:
- '8010:8000'
- '2222:22'
stdin_open: true
tty: true
volumes:
Expand Down
7 changes: 5 additions & 2 deletions docker/run_dev.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env bash
set -e
# Generate SSH host keys (fix for the error)
ssh-keygen -A
/usr/sbin/sshd

# used to generate static files for local development.

python manage.py collectstatic --noinput
su -c 'python manage.py collectstatic --noinput' app

./manage.py runserver 0.0.0.0:8000
su -c './manage.py runserver 0.0.0.0:8000' app
Loading