Skip to content

Instantly share code, notes, and snippets.

@junderw
Created February 24, 2018 00:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save junderw/2de606d9969c768077308582cd4f7153 to your computer and use it in GitHub Desktop.
Save junderw/2de606d9969c768077308582cd4f7153 to your computer and use it in GitHub Desktop.
Dockerfile for running keybase in a container... requires KEYBASEUSER.ss config.json secretkeys.KEYBASEUSER.mpack session.json in the same directory as the Dockerfile... also, if you ever logout, the session.json will change.
FROM ubuntu:16.04
MAINTAINER Jonathan Underwood
# set env vars for linux user and keybase user
ENV LINUX_USER="kbuser" \
KEYBASE_USER="youruser"
# use curl to grab the latest build from keybase.io
RUN apt update && apt install -y \
curl
# make a user to run it
RUN adduser --disabled-password --gecos "" $LINUX_USER
# download the deb and install. exit 0 is to prevent build errors.
WORKDIR /home/$LINUX_USER
RUN curl -O https://prerelease.keybase.io/keybase_amd64.deb
RUN dpkg -i keybase_amd64.deb; exit 0
# install dependencies
RUN apt install -f -y
# need to mkdir with kbuser
USER kbuser
RUN mkdir -p /home/$LINUX_USER/.cache/keybase/; \
mkdir -p /home/$LINUX_USER/.config/keybase/; \
mkdir -p /home/$LINUX_USER/.local/share/keybase/
# return to root
USER root
# Copy the four files for the user session
COPY session.json /home/$LINUX_USER/.cache/keybase/session.json
COPY config.json /home/$LINUX_USER/.config/keybase/config.json
COPY secretkeys.$KEYBASE_USER.mpack /home/$LINUX_USER/.config/keybase/secretkeys.$KEYBASE_USER.mpack
COPY $KEYBASE_USER.ss /home/$LINUX_USER/.local/share/keybase/$KEYBASE_USER.ss
# Make sure they are chowned and chmodded correctly
RUN chown kbuser:kbuser /home/$LINUX_USER/.cache/keybase/session.json; \
chown kbuser:kbuser /home/$LINUX_USER/.config/keybase/config.json; \
chown kbuser:kbuser /home/$LINUX_USER/.config/keybase/secretkeys.$KEYBASE_USER.mpack; \
chown kbuser:kbuser /home/$LINUX_USER/.local/share/keybase/$KEYBASE_USER.ss; \
chmod 0600 /home/$LINUX_USER/.cache/keybase/session.json; \
chmod 0600 /home/$LINUX_USER/.config/keybase/config.json; \
chmod 0600 /home/$LINUX_USER/.config/keybase/secretkeys.$KEYBASE_USER.mpack; \
chmod 0600 /home/$LINUX_USER/.local/share/keybase/$KEYBASE_USER.ss
# Finally run run_keybase to set up all the initial files and you will be logged in
USER $LINUX_USER
RUN run_keybase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment