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

Some code refactoring for the dockerfiles. #14

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
38 changes: 24 additions & 14 deletions lokinet/lokinet-base.dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
FROM debian:stable AS lokinet-base
#use argument instead of lsb-release
ARG DEBIAN_RELEASE=bullseye

FROM debian:${DEBIAN_RELEASE}-slim AS lokinet-base
ENV container docker

ENV RELEASE=${DEBIAN_RELEASE:-bullseye}
#Add oxen public key
ADD --chmod=644 --chown=_apt https://deb.oxen.io/pub.gpg /etc/apt/trusted.gpg.d/lokinet.gpg

# set up packages
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
RUN /bin/bash -c 'apt-get -o=Dpkg::Use-Pty=0 -q update && apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y && apt-get -o=Dpkg::Use-Pty=0 -q install -y --no-install-recommends ca-certificates curl iptables dnsutils lsb-release systemd systemd-sysv cron conntrack iproute2 python3-pip wget'
RUN /bin/bash -c 'curl -so /etc/apt/trusted.gpg.d/lokinet.gpg https://deb.oxen.io/pub.gpg'
RUN /bin/bash -c 'echo "deb https://deb.oxen.io $(lsb_release -sc) main" > /etc/apt/sources.list.d/lokinet.list'
RUN /bin/bash -c 'apt-get -o=Dpkg::Use-Pty=0 -q update && apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y && apt-get -o=Dpkg::Use-Pty=0 -q install -y --no-install-recommends lokinet'
# not sure if wget, lsb-release and curl are needed (maybe they can be removed to make a smaller image?)
RUN DEBIAN_FRONTEND=noninteractive \
&& echo "deb https://deb.oxen.io ${RELEASE} main" > /etc/apt/sources.list.d/lokinet.list \
&& echo "man-db man-db/auto-update boolean false" | debconf-set-selections \
&& apt update -y \
beardstack marked this conversation as resolved.
Show resolved Hide resolved
&& apt full-upgrade -y \
&& apt install -y --no-install-recommends ca-certificates iptables dnsutils systemd systemd-sysv cron conntrack iproute2 python3-pip \
&& apt update -y \
&& apt install -y --no-install-recommends lokinet \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
majestrate marked this conversation as resolved.
Show resolved Hide resolved
&& mkdir -p /var/lib/lokinet/conf.d \
&& mkdir /data && chown _lokinet:_loki /data

# make config dir for lokinet
RUN /bin/bash -c 'mkdir -p /var/lib/lokinet/conf.d'
# set up private data dir for lokinet
RUN /bin/bash -c 'mkdir /data && chown _lokinet:_loki /data'

# print lokinet util
COPY contrib/print-lokinet-address.sh /usr/local/bin/print-lokinet-address.sh
RUN /bin/bash -c 'chmod 700 /usr/local/bin/print-lokinet-address.sh'
COPY --chmod=755 contrib/print-lokinet-address.sh /usr/local/bin/print-lokinet-address.sh

# dns
COPY contrib/lokinet.resolveconf.txt /etc/resolv.conf
RUN /bin/bash -c 'chmod 644 /etc/resolv.conf'
COPY --chmod=644 contrib/lokinet.resolveconf.txt /etc/resolv.conf

STOPSIGNAL SIGRTMIN+3
ENTRYPOINT ["/sbin/init", "verbose", "systemd.unified_cgroup_hierarchy=0", "systemd.legacy_systemd_cgroup_controller=0"]
2 changes: 1 addition & 1 deletion lokinet/lokinet-exit-custom.dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM registry.oxen.rocks/lokinet-exit:latest

RUN /bin/bash -c 'ln -s /var/lib/lokinet/conf.d/custom.ini /data/custom.ini'
RUN ln -s /var/lib/lokinet/conf.d/custom.ini /data/custom.ini
16 changes: 6 additions & 10 deletions lokinet/lokinet-exit.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ COPY contrib/lokinet-exit.ini /var/lib/lokinet/conf.d/exit.ini

# set up system configs
COPY contrib/lokinet-exit-sysctl.conf /etc/sysctl.d/00-lokinet-exit.conf
COPY contrib/lokinet-exit-rc.local.sh /etc/rc.local
RUN /bin/bash -c 'chmod 700 /etc/rc.local'
COPY --chmod=700 contrib/lokinet-exit-rc.local.sh /etc/rc.local

COPY contrib/print-lokinet-address.sh /usr/local/bin/print-lokinet-address.sh
RUN /bin/bash -c 'chmod 700 /usr/local/bin/print-lokinet-address.sh'
COPY --chmod=755 contrib/print-lokinet-address.sh /usr/local/bin/print-lokinet-address.sh

# setup cron jobs
COPY contrib/lokinet-kill-scans.sh /usr/local/bin/lokinet-kill-scans.sh
RUN /bin/bash -c 'chmod 700 /usr/local/bin/lokinet-kill-scans.sh'
COPY contrib/lokinet-update-exit-address.sh /usr/local/bin/lokinet-update-exit-address.sh
RUN /bin/bash -c 'chmod 700 /usr/local/bin/lokinet-update-exit-address.sh'
COPY --chmod=700 contrib/lokinet-kill-scans.sh /usr/local/sbin/lokinet-kill-scans.sh
COPY --chmod=700 contrib/lokinet-update-exit-address.sh /usr/local/sbin/lokinet-update-exit-address.sh

COPY --chmod=644 contrib/lokinet-exit.crontab /etc/cron.d/lokinet-exit

COPY contrib/lokinet-exit.crontab /etc/cron.d/lokinet-exit
RUN /bin/bash -c 'chmod 644 /etc/cron.d/lokinet-exit'
5 changes: 4 additions & 1 deletion lokinet/lokinet-nginx.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM registry.oxen.rocks/lokinet-base:latest

RUN /bin/bash -c 'apt-get -o=Dpkg::Use-Pty=0 -q update && apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y && apt-get -o=Dpkg::Use-Pty=0 -q install -y --no-install-recommends nginx'
RUN DEBIAN_FRONTEND=noninteractive \
&& apt update -y \
&& apt apt full-upgrade -y \
beardstack marked this conversation as resolved.
Show resolved Hide resolved
&& apt install -y --no-install-recommends nginx

# set up configs for lokinet nginx
COPY contrib/lokinet-nginx.ini /var/lib/lokinet/conf.d/nginx.ini