Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Syntax3rror404 committed Aug 24, 2024
1 parent e8d354c commit f792c83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ RUN addgroup --gid 1001 devgroup && \
# SSH configuration for rootless container
RUN mkdir -p /etc/ssh/keys /var/run/sshd && \
ssh-keygen -A && \
ssh-keygen -t rsa -f /etc/ssh/keys/ssh_host_rsa_key -N '' && \
cp /etc/ssh/ssh_host_* /etc/ssh/keys/ && \
chown -R root:root /etc/ssh/keys && \
chmod 600 /etc/ssh/keys/* && \
echo 'dev:dev' | chpasswd && \
Expand All @@ -72,17 +72,17 @@ RUN chown -R dev:devgroup /usr/local /home/dev
# Switch to non-root user
USER dev

# Set environment variables, including PATH to specific directories
ENV PATH="/usr/local/bin:$PATH"
ENV VIRTUAL_ENV="/usr/local/venv"

# Copy entrypoint script
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod 755 /usr/local/bin/entrypoint.sh

# Set environment variables, including PATH to specific directories
ENV PATH="/usr/local/bin:$PATH"
ENV VIRTUAL_ENV="/usr/local/venv"

# Expose SSH port
EXPOSE 2222

# Start the SSH server and any other services via entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
ENTRYPOINT ["entrypoint.sh"]
CMD []
9 changes: 9 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash

# Check if SSH host keys are available; if not, generate them
if [ ! -f /etc/ssh/keys/ssh_host_rsa_key ]; then
echo "Generating new SSH host keys."
ssh-keygen -A
cp /etc/ssh/ssh_host_* /etc/ssh/keys/
chown -R root:root /etc/ssh/keys
chmod 600 /etc/ssh/keys/*
fi

# Start SSH service
/usr/sbin/sshd -D -f /etc/ssh/sshd_config &

Expand Down

0 comments on commit f792c83

Please sign in to comment.