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

Docker Image for running Kippo #241

Closed
aristofanischionis opened this issue Jun 28, 2023 · 3 comments
Closed

Docker Image for running Kippo #241

aristofanischionis opened this issue Jun 28, 2023 · 3 comments

Comments

@aristofanischionis
Copy link

aristofanischionis commented Jun 28, 2023

I was trying to run Kippo locally for a University project and I found it very difficult, so I decided to create a Dockerfile and pushed the Docker image in Docker Hub for anyone who wants to easily run the latest version of Kippo on their local machine. Can I open a PR with the Dockerfile to be included in the official repository? Is anyone interested in this?
The link to the Docker Image I created is here: https://hub.docker.com/r/aristofanischionis/kippo

The Dockerfile has these contents:

# Use an official Python runtime as a parent image
FROM python:2.7-slim

# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' app
USER app

# Set the working directory in the container to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Switch back to root to install dependencies
USER root

# Install necessary packages and clean up
RUN apt-get update && apt-get install -y \
    python-dev=2.7.* \
    build-essential=* && \
    rm -rf /var/lib/apt/lists/*

# Create the data and log directory and set their permissions
RUN mkdir -p /app/data /app/log && \
    chown -R app:app /app/data /app/log

# Install Python packages
RUN pip install --no-cache-dir zope.interface==5.5.2 Twisted==9.0.0 pycrypto==2.6.1 pyasn1==0.5.0

# Modify the start.sh script to include the "-n" option so that it doesn't start in deamon mode and so stay in the foreground, otherwise the container will exit immediately.
RUN sed -i 's/twistd -y kippo.tac -l log\/kippo.log --pidfile kippo.pid/twistd -n -y kippo.tac -l log\/kippo.log --pidfile kippo.pid/' start.sh

# Switch back to the non-root user
USER app

# Make port 2222 available to the world outside this container
EXPOSE 2222

# Run start.sh when the container launches
CMD ["./start.sh"]
@desaster
Copy link
Owner

desaster commented Jun 28, 2023

I haven't maintained kippo, or accepted any pull requests for a long time. Perhaps adding a Dockerfile would be a good last thing to add before archiving the repository, since it makes it easier to run it with the older dependencies that it needs.

The Dockerfile looks good in general, but there's a couple things that probably should be changed:

  • Add dependencies needed for mysql support
  • The last good twisted version that kippo works with is 15.1.0, later versions are broken due to logging changes dblog logging is broken in twisted 15.2.0 #191
    • EDIT: I noticed now that you have twisted 9.0.0, maybe that's okay!
  • Instead of modifying and running start.sh, just change the CMD to run the twistd command directly
  • For normal use you'd probably want to use volumes to bring the logs out of the container for preservation

@aristofanischionis
Copy link
Author

Hi @desaster,
thanks for replying so quickly! I tried to implement your comments.

  • I added mariadb-client and libmariadbclient-dev dependencies as the MySQL client is not available anymore (I think...) - I hope that's fine.
  • I updated twisted version to 15.1.0.
  • I changed the CMD command as you said.
  • I tried to run the container and use volumes to bring out the logs. I was running it like this: docker run -v path/on/host:/app/log -p 2222:2222 kippo:latest but when I was trying to connect to it like this: ssh -p 2222 -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=ssh-dss,ssh-rsa [email protected], after inputting the password for root, I got the following error: shell request failed on channel 0. I tried to fix it by changing the permissions to the file: /app/log/tty, but this didn't work. Any ideas? Thanks a lot.

Here is the updated Dockerfile code:

# Use an official Python runtime as a parent image
FROM python:2.7-slim

# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' app
USER app

# Set the working directory in the container to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Switch back to root to install dependencies
USER root

# Install necessary packages and clean up
RUN apt-get update && apt-get install -y \
    python-dev=2.7.* \
    build-essential=* \
    mariadb-client=* \
    libmariadbclient-dev=* && \
    rm -rf /var/lib/apt/lists/*

# Create the data and log directory and set their permissions
RUN mkdir -p /app/data /app/log /app/log/tty && \
    chown -R 777 /app/log/tty && \
    chown -R app:app /app/data /app/log

# Install Python packages
RUN pip install --no-cache-dir zope.interface==5.5.2 Twisted==15.1.0 pycrypto==2.6.1 pyasn1==0.5.0

# Switch back to the non-root user
USER app

# Make port 2222 available to the world outside thiscontainer
EXPOSE 2222

# Run twistd command when the container launches
CMD ["twistd", "-n", "-y", "kippo.tac", "-l", "log/kippo.log", "--pidfile", "kippo.pid"]

@desaster
Copy link
Owner

desaster commented Aug 2, 2023

I changed the base image to alpine, and added docker-compoyse.yml. PR #242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants