adding env support for logs and data, and defaults in container image.

This commit is contained in:
greg stone
2023-03-02 21:07:56 +00:00
parent 791e04d34c
commit 081013f321
7 changed files with 31 additions and 19 deletions

View File

@@ -45,7 +45,7 @@ for DOCKERFILE in $DOCKERFILES; do
DOCKER_PLATFORM_TAG=$PLATFORM-dev DOCKER_PLATFORM_TAG=$PLATFORM-dev
fi fi
docker build --quiet --progress=plain --platform=$DOCKER_PLATFORM \ docker build --quiet --platform=$DOCKER_PLATFORM \
--build-arg platform=$PLATFORM \ --build-arg platform=$PLATFORM \
--build-arg version=$TARGET_TAG \ --build-arg version=$TARGET_TAG \
--build-arg scratch_version=$SCRATCH_PLATFORM_TAG \ --build-arg scratch_version=$SCRATCH_PLATFORM_TAG \

View File

@@ -19,9 +19,16 @@ USER indra:indra
# Set the data volumes # Set the data volumes
#VOLUME ["/etc/indra"] #VOLUME ["/etc/indra"]
#VOLUME ["/var/indra"] #VOLUME ["/var/indra"]
#VOLUME ["/var/log/indra"]
# :8333 indra peer-to-peer port # :8333 indra peer-to-peer port
# :8334 indra RPC port # :8334 indra RPC port
EXPOSE 8337 8338 EXPOSE 8337 8338
ENTRYPOINT ["/bin/indra", "--config-file=/etc/indra/indra.conf", "--data-dir=/var/indra/data", "--logs-dir=/var/indra/logs"] ENV INDRA_CONF_FILE=/etc/indra/indra.conf
ENV INDRA_DATA_DIR=/var/indra
ENV INDRA_LOGS_DIR=/var/log/indra
ENV INDRA_RPC_UNIX_LISTEN=/var/run/indra/indra.sock
ENTRYPOINT ["/bin/indra"]

View File

@@ -111,14 +111,16 @@ RUN set -ex && echo "adding and permissioning /var directories" \
&& mkdir -pv /var/lnd && chmod 750 /var/lnd && chown lnd:lnd /var/lnd \ && mkdir -pv /var/lnd && chmod 750 /var/lnd && chown lnd:lnd /var/lnd \
&& mkdir -pv /var/lnd/.lnd && chmod 750 /var/lnd/.lnd && chown lnd:lnd /var/lnd/.lnd \ && mkdir -pv /var/lnd/.lnd && chmod 750 /var/lnd/.lnd && chown lnd:lnd /var/lnd/.lnd \
&& mkdir -pv /var/indra && chmod 750 /var/indra && chown indra:indra /var/indra \ && mkdir -pv /var/indra && chmod 750 /var/indra && chown indra:indra /var/indra \
&& mkdir -pv /var/run/indra && chmod 750 /var/run/indra && chown indra:indra /var/run/indra && mkdir -pv /var/run/indra && chmod 750 /var/run/indra && chown indra:indra /var/run/indra \
&& mkdir -pv /var/log/indra && chmod 750 /var/log/indra && chown indra:indra /var/log/indra
RUN set -ex && echo "copying /var directories to root filesystem" \ RUN set -ex && echo "copying /var directories to root filesystem" \
&& cp -rp /var/btcwallet /tmp/root-fs/var/btcwallet \ && cp -rp /var/btcwallet /tmp/root-fs/var/btcwallet \
&& cp -rp /var/btcd /tmp/root-fs/var/btcd \ && cp -rp /var/btcd /tmp/root-fs/var/btcd \
&& cp -rp /var/lnd /tmp/root-fs/var/lnd \ && cp -rp /var/lnd /tmp/root-fs/var/lnd \
&& cp -rp /var/indra /tmp/root-fs/var/indra \ && cp -rp /var/indra /tmp/root-fs/var/indra \
&& cp -rp /var/run /tmp/root-fs/var/run && cp -rp /var/run /tmp/root-fs/var/run \
&& cp -rp /var/log /tmp/root-fs/var/log
# DEBUG # DEBUG
RUN set -ex && echo "checking /var directories on root filesystem" \ RUN set -ex && echo "checking /var directories on root filesystem" \
@@ -130,7 +132,9 @@ RUN set -ex && echo "checking /var directories on root filesystem" \
&& ls -hal /tmp/root-fs/var/lnd \ && ls -hal /tmp/root-fs/var/lnd \
&& ls -hal /tmp/root-fs/var/lnd/.lnd \ && ls -hal /tmp/root-fs/var/lnd/.lnd \
&& ls -hal /tmp/root-fs/var/indra \ && ls -hal /tmp/root-fs/var/indra \
&& ls -hal /tmp/root-fs/var/run/indra && ls -hal /tmp/root-fs/var/run/indra \
&& ls -hal /tmp/root-fs/var/log \
&& ls -hal /tmp/root-fs/var/log/indra
WORKDIR /tmp/root-fs WORKDIR /tmp/root-fs

View File

@@ -88,8 +88,10 @@ func Shutdown() (err error) {
log.I.Ln("shutting down p2p server") log.I.Ln("shutting down p2p server")
if err = p2pHost.Close(); check(err) { if p2pHost != nil {
// continue if err = p2pHost.Close(); check(err) {
// continue
}
} }
log.I.Ln("- p2p server shutdown complete") log.I.Ln("- p2p server shutdown complete")

View File

@@ -6,24 +6,26 @@ import (
func configureUnixSocket() { func configureUnixSocket() {
if viper.GetString(unixPathFlag) == "" { unixPath = viper.GetString(unixPathFlag)
if unixPath == "" {
return return
} }
log.I.Ln("enabling rpc unix listener:") log.I.Ln("enabling rpc unix listener:")
log.I.F("- [/unix%s]", viper.GetString(unixPathFlag)) log.I.F("- [/unix%s]", unixPath)
isUnixSockEnabled = true isUnixSockEnabled = true
} }
func configureTunnel() { func configureTunnel() {
if !viper.GetBool(tunEnableFlag) { isTunnelEnabled = viper.GetBool(tunEnableFlag)
if !isTunnelEnabled {
return return
} }
enableTunnel()
log.I.Ln("enabling rpc tunnel") log.I.Ln("enabling rpc tunnel")
configureTunnelPort() configureTunnelPort()
@@ -32,9 +34,7 @@ func configureTunnel() {
log.I.F("- [/ip4/0.0.0.0/udp/%d /ip6/:::/udp/%d]", viper.GetUint16(tunPortFlag), viper.GetUint16(tunPortFlag)) log.I.F("- [/ip4/0.0.0.0/udp/%d /ip6/:::/udp/%d]", viper.GetUint16(tunPortFlag), viper.GetUint16(tunPortFlag))
configureTunnelKey() configureTunnelKey()
configurePeerWhitelist() configurePeerWhitelist()
} }
func configureTunnelKey() { func configureTunnelKey() {
@@ -85,9 +85,8 @@ func configurePeerWhitelist() {
pubKey.Decode(peer) pubKey.Decode(peer)
tunWhitelist = append(tunWhitelist, pubKey)
log.I.Ln("-", pubKey.Encode()) log.I.Ln("-", pubKey.Encode())
tunWhitelist = append(tunWhitelist, pubKey)
} }
} }

View File

@@ -45,6 +45,8 @@ func start() {
var err error var err error
createTunnel()
if err = startTunnel(server); check(err) { if err = startTunnel(server); check(err) {
startupErrors <- err startupErrors <- err
return return

View File

@@ -29,12 +29,10 @@ var (
tunnelMTU int = 1420 tunnelMTU int = 1420
) )
func enableTunnel() { func createTunnel() {
var err error var err error
isTunnelEnabled = true
if tunnel, network, err = netstack.CreateNetTUN([]netip.Addr{deviceRPCIP}, []netip.Addr{}, tunnelMTU); check(err) { if tunnel, network, err = netstack.CreateNetTUN([]netip.Addr{deviceRPCIP}, []netip.Addr{}, tunnelMTU); check(err) {
startupErrors <- err startupErrors <- err
return return