Skip to content

Commit

Permalink
Merge pull request #774 from signum-network/feat/docker-updates
Browse files Browse the repository at this point in the history
Updated Dockerfiles
  • Loading branch information
ohager authored Jan 17, 2024
2 parents b793975 + 9550ba3 commit 38676e2
Show file tree
Hide file tree
Showing 20 changed files with 264 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.github/
.gradle/
.idea/
bin/
build/
doc/
t/
db/
target/
openapi/node_modules/
temp/

16 changes: 9 additions & 7 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
# DOCKERHUB_REPO
# This workflow will use them automatically.

name: Publish Docker image
# FIXME: Refactor this workflow using matrix and the new docker args

on:
release:
types: [released]
workflow_dispatch:
name: Publish Docker images

on: workflow_dispatch
# TODO: put this back once the docker files work correctly
# release:
# types: [released]

jobs:
publish-h2-image:
Expand Down Expand Up @@ -43,7 +45,7 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
file: 'Dockerfile.h2'
file: './docker/mainnet/h2/Dockerfile'
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand Down Expand Up @@ -76,7 +78,7 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
file: 'Dockerfile.mariadb'
file: './docker/mainnet/mariadb/Dockerfile'
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand Down
97 changes: 97 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Build the node software
#FROM gradle:7.3.3-jdk11 as builder
FROM amazoncorretto:11-alpine-jdk as builder
RUN apk update && apk upgrade \
&& apk add --no-cache --update coreutils bind-tools git unzip wget curl nodejs npm \
&& rm -rf /var/cache/apk/*

WORKDIR /signum-node

COPY . .

RUN node -v
RUN npm -v

# Build Signum Node Jar
RUN chmod +x /signum-node/gradlew \
&& /signum-node/gradlew clean dist jdeps \
--no-daemon \
-Pjdeps.recursive=true \
-Pjdeps.ignore.missing.deps=true \
-Pjdeps.print.module.deps=true

# Unpack the build to /signum
RUN unzip -o build/distributions/signum-node.zip -d /signum

# provide needed update scripts
RUN chmod +x update-phoenix.sh
RUN chmod +x update-classic.sh
COPY update-phoenix.sh /signum/update-phoenix.sh
COPY update-classic.sh /signum/update-classic.sh

WORKDIR /signum

# Clean up /signum
RUN rm -rf /signum/signum-node.exe 2> /dev/null || true \
&& rm -rf /signum/signum-node.zip 2> /dev/null || true

## Create a custom JRE
RUN $JAVA_HOME/bin/jlink \
--add-modules $(cat /signum-node/build/reports/jdeps/print-module-deps-main.txt) \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /jre

RUN mkdir -p /requirements \
&& ldd /jre/bin/java | awk 'NF == 4 { system("cp --parents " $3 " /requirements") }'

# Prepare final image
FROM alpine:3.18
LABEL name="Signum Node"
LABEL description="This is the official Signum Node image"
LABEL credits="gittrekt,damccull,ohager"
ENV JAVA_HOME=/jre
ENV PATH="${JAVA_HOME}/bin:${PATH}"

# minimum required env needed for wallet update scripts on container restarts -> see start-node.sh
RUN apk update && apk upgrade \
&& apk add --no-cache --update coreutils bind-tools git unzip wget curl bash \
&& rm -rf /var/cache/apk/*

COPY --from=builder /jre $JAVA_HOME
COPY --from=builder /signum /signum
COPY --from=builder /requirements/ /

WORKDIR /signum

VOLUME ["/conf", "/db"]
RUN ln -s /conf /signum/conf
RUN ln -s /db /signum/db

# We use the bootstrap folder to copy the config files to the host machine in the start-node.sh script
# use one of [h2,mariadb,postgres]
ARG database=h2
ARG network=mainnet

# Injectable ports defaulting to mainnet
ARG port_p2p=8123
ARG port_http=8125
ARG port_ws=8126

RUN mkdir ./bootstrap
COPY conf/logging-default.properties ./bootstrap/logging-default.properties
COPY conf/node-default.properties ./bootstrap/node-default.properties
COPY conf/${network}/node.${database}.properties ./bootstrap/node.properties

COPY docker/scripts/start-node.sh ./start-node.sh
RUN chmod +x start-node.sh

# Clean up
RUN rm signum-node.exe 2> /dev/null || true
RUN rm signum-node.zip 2> /dev/null || true

EXPOSE $port_ws $port_http $port_p2p

ENTRYPOINT [ "./start-node.sh" ]
34 changes: 0 additions & 34 deletions Dockerfile.h2

This file was deleted.

34 changes: 0 additions & 34 deletions Dockerfile.mariadb

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ git push --tags

# Docker

See [DOCKER.md](./DOCKER.md) for information on running and building docker images.
See [DOCKER.md](./docker/DOCKER.md) for information on running and building docker images.

# Database Development

Expand All @@ -282,6 +282,7 @@ To get more details about how to work with database changes look at [more detail
Main Developer: [jjos2372](https://github.com/jjos2372). Donation address: [S-JJQS-MMA4-GHB4-4ZNZU](https://explorer.signum.network/?action=account&account=3278233074628313816)
Frequent Contributors:
- [ohager](https://github.com/ohager). Donation address: [S-9K9L-4CB5-88Y5-F5G4Z](https://explorer.signum.network/?action=account&account=16107620026796983538)
- [frankTheTank72](https://github.com/frankTheTank72).
- [damccull](https://github.com/damccull).

For more information, see [Credits](doc/Credits.md)
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
id "de.undercouch.download" version "5.5.0"
id 'jacoco'
id "com.github.node-gradle.node" version "7.0.1"
id 'org.kordamp.gradle.jdeps' version '0.20.0'
}

java {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ API.allowed = *

# Database connection JDBC url
# Append ;AUTO_SERVER=TRUE to enable automatic mixed mode access.
DB.Url=jdbc:mariadb://localhost:3306/signum
DB.Url=jdbc:mariadb://localhost:3306/signum?sslMode=DISABLED
DB.Username=root
DB.Password=signum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ API.allowed = *

#### DATABASE ####

# Database connection JDBC url
# Run following scripts to initialize


DB.Url=jdbc:postgresql://localhost:5432/signum
DB.Url=jdbc:postgresql://localhost:5432/signum?sslMode=disabled
DB.Username=signumnode
DB.Password=s1gn00m_n0d3
6 changes: 0 additions & 6 deletions conf/testnet/node-default.properties

This file was deleted.

13 changes: 13 additions & 0 deletions conf/testnet/node.h2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node.network = signum.net.TestnetNetwork

#### API SERVER ####
API.Listen = 0.0.0.0
API.allowed = *

#### DATABASE ####
# Reduces the database file size dramatically, if on... but needs time on shutdown
Db.H2.DefragOnShutdown = on
# Database connection JDBC url
DB.Url=jdbc:h2:file:/db/signum-test;DB_CLOSE_ON_EXIT=FALSE
DB.Username=
DB.Password=
13 changes: 13 additions & 0 deletions conf/testnet/node.mariadb.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node.network = signum.net.TestnetNetwork

#### API SERVER ####
API.Listen = 0.0.0.0
API.allowed = *

#### DATABASE ####

# Database connection JDBC url
# Append ;AUTO_SERVER=TRUE to enable automatic mixed mode access.
DB.Url=jdbc:mariadb://localhost:3306/signum-test?sslMode=DISABLED
DB.Username=root
DB.Password=signum
9 changes: 9 additions & 0 deletions conf/testnet/node.postgres.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#### API SERVER ####
API.Listen = 0.0.0.0
API.allowed = *

#### DATABASE ####

DB.Url=jdbc:postgresql://localhost:5432/signum-test?sslMode=disabled
DB.Username=signumnode
DB.Password=s1gn00m_n0d3
Loading

0 comments on commit 38676e2

Please sign in to comment.