mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-23 20:27:37 +01:00
rewrite Dockerfile to use multi-stage docker build and replace gosu with
su-exec
This commit is contained in:
parent
e77037c2b8
commit
40d2dea123
2 changed files with 65 additions and 0 deletions
41
Dockerfile
Normal file
41
Dockerfile
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
FROM alpine:latest as builder
|
||||||
|
|
||||||
|
# We will build docker image in 2 stages.
|
||||||
|
# This is 1st stage and we will use it to build i2pd executable.
|
||||||
|
|
||||||
|
# 1. install deps
|
||||||
|
RUN apk add --no-cache build-base libtool boost-dev openssl-dev zlib-dev
|
||||||
|
|
||||||
|
# 2. copy sources
|
||||||
|
WORKDIR /src
|
||||||
|
COPY . /src
|
||||||
|
|
||||||
|
# 3. build
|
||||||
|
RUN make -j$(nproc)
|
||||||
|
# 4. strip executable
|
||||||
|
RUN strip --strip-all i2pd
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
# This is 2nd stage and it will be used to run i2pd.
|
||||||
|
|
||||||
|
# 1. create user to run i2pd from it
|
||||||
|
RUN mkdir /var/lib/i2pd && adduser -S -h /var/lib/i2pd i2pd \
|
||||||
|
&& chown -R i2pd:nobody /var/lib/i2pd
|
||||||
|
|
||||||
|
# 2. install required libraries to run i2pd
|
||||||
|
RUN apk add --no-cache boost-system boost-date_time boost-filesystem \
|
||||||
|
boost-program_options libstdc++ libgcc openssl zlib su-exec
|
||||||
|
|
||||||
|
# 3. copy i2pd binary from 1st stage
|
||||||
|
COPY --from=builder /src/i2pd /usr/local/bin/
|
||||||
|
|
||||||
|
# 4. copy entrypoint.sh
|
||||||
|
COPY build/docker/entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod a+x /entrypoint.sh
|
||||||
|
|
||||||
|
VOLUME [ "/var/lib/i2pd" ]
|
||||||
|
|
||||||
|
EXPOSE 7070 4444 4447 7656 2827 7654 7650
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
24
build/docker/entrypoint.sh
Normal file
24
build/docker/entrypoint.sh
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
ARGS=""
|
||||||
|
if [ "${ENABLE_IPV6}" != "" ]; then
|
||||||
|
ARGS="${ARGS} –ipv6"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${LOGLEVEL}" != "" ]; then
|
||||||
|
ARGS="${ARGS} –loglevel=${LOGLEVEL}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${ENABLE_AUTH}" != "" ]; then
|
||||||
|
ARGS="${ARGS} –http.auth"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# To make ports exposeable
|
||||||
|
DEFAULT_ARGS=" –http.address=0.0.0.0 –httpproxy.address=0.0.0.0 -socksproxy.address=0.0.0.0 –sam.address=0.0.0.0 –bob.address=0.0.0.0 –i2cp.address=0.0.0.0 –i2pcontrol.port=0.0.0.0 –upnp.enabled=false -service "
|
||||||
|
|
||||||
|
chown -R i2pd:nobody /var/lib/i2pd && chmod u+rw /var/lib/i2pd
|
||||||
|
|
||||||
|
su-exec i2pd i2pd $DEFAULT_ARGS $ARGS
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue