Add support for building ubuntu:20.04-based docker images + some automation
This commit is contained in:
parent
f7372fc393
commit
348a4b0865
9 changed files with 200 additions and 55 deletions
42
Dockerfile
42
Dockerfile
|
@ -1,42 +0,0 @@
|
|||
FROM alpine:3.13
|
||||
|
||||
# Base settings
|
||||
ENV HOME /root
|
||||
|
||||
# Install packages
|
||||
|
||||
RUN apk --update --no-cache --no-progress add \
|
||||
python3 python3-dev py3-pip \
|
||||
libffi-dev musl-dev \
|
||||
gcc g++ make \
|
||||
automake autoconf libtool \
|
||||
openssl \
|
||||
tor
|
||||
|
||||
COPY requirements.txt /root/requirements.txt
|
||||
|
||||
RUN pip3 install -r /root/requirements.txt \
|
||||
&& apk del python3-dev gcc libffi-dev musl-dev make \
|
||||
&& echo "ControlPort 9051" >> /etc/tor/torrc \
|
||||
&& echo "CookieAuthentication 1" >> /etc/tor/torrc
|
||||
|
||||
RUN python3 -V \
|
||||
&& python3 -m pip list \
|
||||
&& tor --version \
|
||||
&& openssl version
|
||||
|
||||
# Add Zeronet source
|
||||
|
||||
COPY . /root
|
||||
VOLUME /root/data
|
||||
|
||||
# Control if Tor proxy is started
|
||||
ENV ENABLE_TOR false
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
# Set upstart command
|
||||
CMD (! ${ENABLE_TOR} || tor&) && python3 zeronet.py --ui_ip 0.0.0.0 --fileserver_port 26552
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 43110 26552
|
1
Dockerfile
Symbolic link
1
Dockerfile
Symbolic link
|
@ -0,0 +1 @@
|
|||
dockerfiles/Dockerfile.alpine
|
11
build-docker-images.sh
Executable file
11
build-docker-images.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
prefix="${1:-local/}"
|
||||
|
||||
for dokerfile in dockerfiles/Dockerfile.* ; do
|
||||
suffix="`echo "$dokerfile" | sed 's/.*\/Dockerfile\.//'`"
|
||||
image_name="${prefix}zeronet:$suffix"
|
||||
echo "DOCKER BUILD $image_name"
|
||||
docker build -f "$dokerfile" -t "$image_name" .
|
||||
done
|
1
dockerfiles/Dockerfile.alpine
Symbolic link
1
dockerfiles/Dockerfile.alpine
Symbolic link
|
@ -0,0 +1 @@
|
|||
Dockerfile.alpine3.13
|
44
dockerfiles/Dockerfile.alpine3.13
Normal file
44
dockerfiles/Dockerfile.alpine3.13
Normal file
|
@ -0,0 +1,44 @@
|
|||
# THIS FILE IS AUTOGENERATED BY gen-dockerfiles.sh.
|
||||
# SEE zeronet-Dockerfile FOR THE SOURCE FILE.
|
||||
|
||||
FROM alpine:3.13
|
||||
|
||||
# Base settings
|
||||
ENV HOME /root
|
||||
|
||||
# Install packages
|
||||
|
||||
# Install packages
|
||||
|
||||
COPY install-dep-packages.sh /root/install-dep-packages.sh
|
||||
|
||||
RUN /root/install-dep-packages.sh install
|
||||
|
||||
COPY requirements.txt /root/requirements.txt
|
||||
|
||||
RUN pip3 install -r /root/requirements.txt \
|
||||
&& /root/install-dep-packages.sh remove-makedeps \
|
||||
&& echo "ControlPort 9051" >> /etc/tor/torrc \
|
||||
&& echo "CookieAuthentication 1" >> /etc/tor/torrc
|
||||
|
||||
RUN python3 -V \
|
||||
&& python3 -m pip list \
|
||||
&& tor --version \
|
||||
&& openssl version
|
||||
|
||||
# Add Zeronet source
|
||||
|
||||
COPY . /root
|
||||
VOLUME /root/data
|
||||
|
||||
# Control if Tor proxy is started
|
||||
ENV ENABLE_TOR false
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
# Set upstart command
|
||||
CMD (! ${ENABLE_TOR} || tor&) && python3 zeronet.py --ui_ip 0.0.0.0 --fileserver_port 26552
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 43110 26552
|
||||
|
1
dockerfiles/Dockerfile.ubuntu
Symbolic link
1
dockerfiles/Dockerfile.ubuntu
Symbolic link
|
@ -0,0 +1 @@
|
|||
Dockerfile.ubuntu20.04
|
44
dockerfiles/Dockerfile.ubuntu20.04
Normal file
44
dockerfiles/Dockerfile.ubuntu20.04
Normal file
|
@ -0,0 +1,44 @@
|
|||
# THIS FILE IS AUTOGENERATED BY gen-dockerfiles.sh.
|
||||
# SEE zeronet-Dockerfile FOR THE SOURCE FILE.
|
||||
|
||||
FROM ubuntu:20.04
|
||||
|
||||
# Base settings
|
||||
ENV HOME /root
|
||||
|
||||
# Install packages
|
||||
|
||||
# Install packages
|
||||
|
||||
COPY install-dep-packages.sh /root/install-dep-packages.sh
|
||||
|
||||
RUN /root/install-dep-packages.sh install
|
||||
|
||||
COPY requirements.txt /root/requirements.txt
|
||||
|
||||
RUN pip3 install -r /root/requirements.txt \
|
||||
&& /root/install-dep-packages.sh remove-makedeps \
|
||||
&& echo "ControlPort 9051" >> /etc/tor/torrc \
|
||||
&& echo "CookieAuthentication 1" >> /etc/tor/torrc
|
||||
|
||||
RUN python3 -V \
|
||||
&& python3 -m pip list \
|
||||
&& tor --version \
|
||||
&& openssl version
|
||||
|
||||
# Add Zeronet source
|
||||
|
||||
COPY . /root
|
||||
VOLUME /root/data
|
||||
|
||||
# Control if Tor proxy is started
|
||||
ENV ENABLE_TOR false
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
# Set upstart command
|
||||
CMD (! ${ENABLE_TOR} || tor&) && python3 zeronet.py --ui_ip 0.0.0.0 --fileserver_port 26552
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 43110 26552
|
||||
|
34
dockerfiles/gen-dockerfiles.sh
Executable file
34
dockerfiles/gen-dockerfiles.sh
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
die() {
|
||||
echo "$@" > /dev/stderr
|
||||
exit 1
|
||||
}
|
||||
|
||||
for os in alpine:3.13 ubuntu:20.04 ; do
|
||||
prefix="`echo "$os" | sed -e 's/://'`"
|
||||
short_prefix="`echo "$os" | sed -e 's/:.*//'`"
|
||||
|
||||
zeronet="zeronet-Dockerfile"
|
||||
|
||||
dockerfile="Dockerfile.$prefix"
|
||||
dockerfile_short="Dockerfile.$short_prefix"
|
||||
|
||||
echo "GEN $dockerfile"
|
||||
|
||||
if ! test -f "$zeronet" ; then
|
||||
die "No such file: $zeronet"
|
||||
fi
|
||||
|
||||
echo "\
|
||||
# THIS FILE IS AUTOGENERATED BY gen-dockerfiles.sh.
|
||||
# SEE $zeronet FOR THE SOURCE FILE.
|
||||
|
||||
FROM $os
|
||||
|
||||
`cat "$zeronet"`
|
||||
" > "$dockerfile.tmp" && mv "$dockerfile.tmp" "$dockerfile" && ln -s -f "$dockerfile" "$dockerfile_short"
|
||||
done
|
||||
|
|
@ -1,14 +1,16 @@
|
|||
FROM alpine:3.12
|
||||
|
||||
# Base settings
|
||||
ENV HOME /root
|
||||
|
||||
# Install packages
|
||||
|
||||
COPY install-dep-packages.sh /root/install-dep-packages.sh
|
||||
|
||||
RUN /root/install-dep-packages.sh install
|
||||
|
||||
COPY requirements.txt /root/requirements.txt
|
||||
|
||||
#Install ZeroNet
|
||||
RUN apk --update --no-cache --no-progress add python3 python3-dev gcc libffi-dev musl-dev make tor openssl \
|
||||
&& pip3 install -r /root/requirements.txt \
|
||||
&& apk del python3-dev gcc libffi-dev musl-dev make \
|
||||
RUN pip3 install -r /root/requirements.txt \
|
||||
&& /root/install-dep-packages.sh remove-makedeps \
|
||||
&& echo "ControlPort 9051" >> /etc/tor/torrc \
|
||||
&& echo "CookieAuthentication 1" >> /etc/tor/torrc
|
||||
|
||||
|
@ -18,6 +20,7 @@ RUN python3 -V \
|
|||
&& openssl version
|
||||
|
||||
# Add Zeronet source
|
||||
|
||||
COPY . /root
|
||||
VOLUME /root/data
|
||||
|
||||
|
@ -31,4 +34,3 @@ CMD (! ${ENABLE_TOR} || tor&) && python3 zeronet.py --ui_ip 0.0.0.0 --fileserver
|
|||
|
||||
# Expose ports
|
||||
EXPOSE 43110 26552
|
||||
|
49
install-dep-packages.sh
Executable file
49
install-dep-packages.sh
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
do_alpine() {
|
||||
local deps="python3 py3-pip openssl tor"
|
||||
local makedeps="python3-dev gcc g++ libffi-dev musl-dev make automake autoconf libtool"
|
||||
|
||||
case "$1" in
|
||||
install)
|
||||
apk --update --no-cache --no-progress add $deps $makedeps
|
||||
;;
|
||||
remove-makedeps)
|
||||
apk del $makedeps
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
do_ubuntu() {
|
||||
local deps="python3 python3-pip openssl tor"
|
||||
local makedeps="python3-dev gcc g++ libffi-dev make automake autoconf libtool"
|
||||
|
||||
case "$1" in
|
||||
install)
|
||||
apt-get update && \
|
||||
apt-get install --no-install-recommends -y $deps $makedeps && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
;;
|
||||
remove-makedeps)
|
||||
apt-get remove -y $makedeps
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if test -f /etc/os-release ; then
|
||||
. /etc/os-release
|
||||
elif test -f /usr/lib/os-release ; then
|
||||
. /usr/lib/os-release
|
||||
else
|
||||
echo "No such file: /etc/os-release" > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$ID" in
|
||||
ubuntu) do_ubuntu "$@" ;;
|
||||
alpine) do_alpine "$@" ;;
|
||||
*)
|
||||
echo "Unsupported OS ID: $ID" > /dev/stderr
|
||||
exit 1
|
||||
esac
|
Loading…
Reference in a new issue