Compare commits

...

5 Commits

Author SHA1 Message Date
329972fc1e Change Docker to mount a persistent i2p.dir.config 2021-04-26 12:47:40 +01:00
b424f10fd2 Merge 2021-04-26 12:34:10 +01:00
b155f2f8d6 Merge branch 'master' of 127.0.0.1:zlatinb/i2p.i2p 2021-04-25 00:18:56 +01:00
ffcfb12c2f Merge branch 'susimail-fix-mangling' into 'master'
Update read buffer offset.  Fixes occasional mangling, trac ticket 2765

See merge request zlatinb/i2p.i2p!1
2021-04-24 23:09:01 +00:00
7631091c39 Update read buffer offset. Fixes occasional mangling, trac ticket 2765 2021-04-25 00:07:25 +01:00
6 changed files with 69 additions and 43 deletions

View File

@ -1,7 +0,0 @@
#!/usr/bin/expect
set timeout 15;
spawn java -jar /tmp/i2pinstall.jar -console
expect {
-re ".*press 1 to continue, 2 to quit, 3 to redisplay" {send "1\r"; exp_continue;}
-re "Select target path *" {send "/opt/i2p\r"; exp_continue;}
}

View File

@ -1,47 +1,32 @@
# Use a multi-stage build to reduce the size of the resulting image
# We need alpine >v3 in order to install an apache-ant > 1.9
FROM alpine:3 as builder
ENV I2P_PREFIX="/opt/i2p"
FROM jlesage/baseimage:alpine-3.10-glibc
ENV APP_HOME="/i2p"
WORKDIR /tmp/build
COPY . ./
COPY . .
# Build installer
RUN apk --no-cache add build-base gettext tar bzip2 apache-ant openjdk8 expect
# Build package
RUN add-pkg openjdk8-jre
RUN add-pkg --virtual build-base gettext tar bzip2 apache-ant openjdk8
RUN echo "noExe=true" >> build.properties
RUN ant installer-linux
RUN mkdir -p /opt
RUN mv i2pinstall*.jar /tmp/i2pinstall.jar
RUN ant clean pkg
RUN del-pkg build-base gettext tar bzip2 apache-ant openjdk8
# Install i2p using the installer into I2P_PREFIX
RUN expect -f ./Docker.expt
RUN cd ${I2P_PREFIX}
RUN rm -fr man docs *.bat *.command *.app
# Second stage only using the installer from the last stage
# ---------------------------------------------------------
# We can't use alpine here as the java service wrapper is built with glibc
# alpine uses musl
FROM openjdk:11.0-jre-slim
ARG I2P_UID=1000
ARG I2P_USER=i2p
ENV I2P_PREFIX="/opt/i2p"
ENV PATH=${I2P_PREFIX}/bin:$PATH
# "install" files
RUN mkdir -p ${APP_HOME}
RUN mv pkg-temp/* ${APP_HOME}
# "install" i2p by copying over installed files
COPY --from=builder /opt/i2p ${I2P_PREFIX}
COPY docker/* /opt/i2p/
COPY docker/rootfs/ /
# Setup user and fix permissions in
RUN adduser --system --uid ${I2P_UID} --home /user ${I2P_USER} \
&& chown -R ${I2P_USER} /user \
&& chown -R ${I2P_USER} ${I2P_PREFIX} \
&& chmod -R u+rwx ${I2P_PREFIX}
# Mount home
VOLUME ["${APP_HOME}/.i2p"]
EXPOSE 7654 7656 7657 7658 4444 6668 8998 7659 7660 4445
USER i2p
ENTRYPOINT [ "/opt/i2p/i2psvc" ]
CMD [ "/opt/i2p/wrapper.config", "wrapper.pidfile=/var/tmp/i2p.pid", "wrapper.name=i2p", "wrapper.displayname=\"I2P Service\"" , "wrapper.statusfile=/var/tmp/i2p.status", "wrapper.java.statusfile=/var/tmp/i2p.java.status", "wrapper.logfile=/var/tmp/wrapper.log" ]
# Metadata.
LABEL \
org.label-schema.name="i2p" \
org.label-schema.description="Docker container for I2P" \
org.label-schema.version="1.0" \
org.label-schema.vcs-url="https://github.com/i2p/i2p.i2p" \
org.label-schema.schema-version="1.0"

View File

@ -0,0 +1,27 @@
#!/usr/bin/with-contenv sh
#
# Add the app user to the password and group databases. This is needed just to
# make sure that mapping between the user/group ID and its name is possible.
#
set -e # Exit immediately if a command exits with a non-zero status.
set -u # Treat unset variables as an error.
cp /defaults/passwd /etc/passwd
cp /defaults/group /etc/group
cp /defaults/shadow /etc/shadow
chown root:shadow /etc/shadow
chmod 640 /etc/shadow
echo "$APP_USER:x:$USER_ID:$GROUP_ID::${APP_HOME:-/dev/null}:/sbin/nologin" >> /etc/passwd
echo "$APP_USER:x:$GROUP_ID:" >> /etc/group
# Make sure APP_HOME is editable by the user
if [[ -n "$APP_HOME" ]] ; then
chown -R "$APP_USER" "$APP_HOME"
chmod -R u+rw "$APP_HOME"
fi
# vim:ft=sh:ts=4:sw=4:et:sts=4

21
docker/rootfs/startapp.sh Normal file
View File

@ -0,0 +1,21 @@
#!/bin/sh
set -e
# Explicitly define HOME otherwise it might not have been set
export HOME=/i2p
export I2P=${HOME}/i2p
echo "Starting I2P"
cd $HOME
export CLASSPATH=.
for jar in `ls lib/*.jar`; do
CLASSPATH=${CLASSPATH}:${jar}
done
JAVAOPTS="-Djava.net.preferIPv4Stack=false -Djava.library.path=${I2P}:${I2P}/lib -Di2p.dir.base=${I2P} -Di2p.dir.config=${HOME}/.i2p -DloggerFilenameOverride=logs/log-router-@.txt"
java -cp "${CLASSPATH}" ${JAVA_OPTS} net.i2p.router.RouterLaunch