Skip to content

Commit 982ee2d

Browse files
authored
feat: changed container work dir from app to opt (#872)
Signed-off-by: Alex Kehayov <aleks.kehayov@limechain.tech>
1 parent 5598d82 commit 982ee2d

File tree

16 files changed

+90
-43
lines changed

16 files changed

+90
-43
lines changed

block-node/app/docker/Dockerfile

+13-9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ ARG SOURCE_DATE_EPOCH="0"
1414
FROM ubuntu:${UBUNTU_TAG} AS ubuntu-origin
1515
# Define Build Arguments
1616
ARG SOURCE_DATE_EPOCH
17+
ARG UID=2000
18+
ARG GID=2000
19+
ARG BN_WORKDIR="/opt/hiero/block-node"
1720

1821
# Define Standard Environment Variables
1922
ENV DEBIAN_FRONTEND=noninteractive
@@ -64,14 +67,14 @@ RUN set -eux; \
6467
rm -f /tmp/openjdk.tar.gz /usr/local/java/lib/src.zip;
6568

6669

67-
RUN groupadd --gid 2000 hedera && \
68-
useradd --no-user-group --create-home --uid 2000 --gid 2000 --shell /bin/bash hedera
70+
RUN groupadd --gid ${GID} hedera && \
71+
useradd --no-user-group --create-home --uid ${UID} --gid ${GID} --shell /bin/bash hedera
6972

7073
# Define version
7174
ARG VERSION
7275

7376
# Set the working directory inside the container
74-
WORKDIR /app
77+
WORKDIR ${BN_WORKDIR}
7578

7679
# Copy Distribution TAR file
7780
# Ignore Codacy, the `distributions` context is set on command line and
@@ -82,15 +85,15 @@ COPY --from=distributions block-node-app-${VERSION}.tar .
8285
RUN tar -xvf block-node-app-${VERSION}.tar
8386

8487
# Create a log directory
85-
RUN mkdir -p /app/logs/config
88+
RUN mkdir -p ${BN_WORKDIR}/logs/config
8689

8790
# Copy the logging properties file
88-
COPY logging.properties /app/logs/config/logging.properties
91+
COPY logging.properties ${BN_WORKDIR}/logs/config/logging.properties
8992

9093
WORKDIR /
9194

9295
# Ensure proper file permissions
93-
RUN chown -R 2000:2000 /app /opt
96+
RUN chown -R $UID:$GID ${BN_WORKDIR}
9497

9598
########################################
9699
#### Deterministic Build Hack ####
@@ -130,6 +133,7 @@ ENV DEBIAN_FRONTEND=noninteractive
130133
ENV JAVA_VERSION="jdk-21.0.7+6"
131134
ENV JAVA_HOME=/usr/local/java
132135
ENV PATH=${JAVA_HOME}/bin:${PATH}
136+
ENV BN_WORKDIR=/opt/hiero/block-node
133137

134138
# Install Java
135139
COPY --from=java-builder ${JAVA_HOME}/ ${JAVA_HOME}/
@@ -138,12 +142,12 @@ COPY --from=java-builder ${JAVA_HOME}/ ${JAVA_HOME}/
138142
EXPOSE 8080/tcp
139143

140144
USER hedera
141-
WORKDIR /app
145+
WORKDIR ${BN_WORKDIR}
142146

143147
# HEALTHCHECK for liveness and readiness
144148
HEALTHCHECK --interval=30s --timeout=10s --start-period=3s --retries=3 \
145149
CMD curl -f http://localhost:8080/healthz/livez || exit 1 && \
146150
curl -f http://localhost:8080/healthz/readyz || exit 1
147151

148-
# RUN the bin script for starting the server app
149-
ENTRYPOINT ["/bin/bash", "-c", "/app/block-node-app-${VERSION}/bin/block-node-app"]
152+
# RUN the bin script for starting the server
153+
ENTRYPOINT ["/bin/bash", "-c", "${BN_WORKDIR}/block-node-app-${VERSION}/bin/block-node-app"]

block-node/app/docker/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
container_name: block-node-server
44
image: block-node-server:${VERSION}
55
volumes:
6-
- ./logging.properties:/app/logs/config/logging.properties
6+
- ./logging.properties:/opt/hiero/block-node/logs/config/logging.properties
77
env_file:
88
- .env
99
ports:

block-node/app/docker/logging.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
6363
# FileHandler properties
6464
################################################################################
6565
# The pattern for the output file name.
66-
java.util.logging.FileHandler.pattern = /app/logs/blocknode-%g.log
66+
java.util.logging.FileHandler.pattern = /opt/hiero/block-node/logs/blocknode-%g.log
6767
# Set append to true if you want to keep appending to existing files
6868
java.util.logging.FileHandler.append = true
6969
# The limit in bytes before a new file is started.

block-node/app/docker/update-env.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ project_version=$1
1818
echo "VERSION=$project_version" > .env
1919
echo "REGISTRY_PREFIX=" >> .env
2020
# Storage root path, this is temporary until we have a proper .properties file for all configs
21-
echo "BLOCKNODE_STORAGE_ROOT_PATH=/app/storage" >> .env
21+
echo "BLOCKNODE_STORAGE_ROOT_PATH=/opt/hiero/block-node/storage" >> .env
2222

2323
if [ true = "$is_smoke_test" ]; then
2424
# add smoke test variables
@@ -33,11 +33,11 @@ fi
3333
if [ true = "$is_debug" ]; then
3434
# The server will wait for the debugger to attach on port 5005
3535
# JProfiler can attach on port 8849
36-
echo "JAVA_TOOL_OPTIONS='-Djava.util.logging.config.file=/app/logs/config/logging.properties -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' -agentpath:/path/to/libjprofilerti.so=port=8849 " >> .env
36+
echo "JAVA_TOOL_OPTIONS='-Djava.util.logging.config.file=/opt/hiero/block-node/logs/config/logging.properties -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' -agentpath:/path/to/libjprofilerti.so=port=8849 " >> .env
3737
else
3838
# we set normally the JAVA_TOOL_OPTIONS
3939
# file is mounted in the docker-compose.yml, changes to the file will be reflected in the container by simply restarting it
40-
echo "JAVA_TOOL_OPTIONS='-Djava.util.logging.config.file=/app/logs/config/logging.properties '" >> .env
40+
echo "JAVA_TOOL_OPTIONS='-Djava.util.logging.config.file=/opt/hiero/block-node/logs/config/logging.properties '" >> .env
4141
fi
4242
# Output the values
4343
echo ".env properties:"

block-node/block-providers/files.historic/src/main/java/org/hiero/block/node/blocks/files/historic/FilesHistoricConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
@ConfigData("files.historic")
2626
public record FilesHistoricConfig(
27-
@Loggable @ConfigProperty(defaultValue = "/opt/hashgraph/blocknode/data/historic") Path rootPath,
27+
@Loggable @ConfigProperty(defaultValue = "/opt/hiero/block-node/data/historic") Path rootPath,
2828
@Loggable @ConfigProperty(defaultValue = "ZSTD") CompressionType compression,
2929
@Loggable @ConfigProperty(defaultValue = "4") @Min(1) @Max(6) int powersOfTenPerZipFileContents) {
3030
/**

block-node/block-providers/files.historic/src/test/java/org/hiero/block/node/blocks/files/historic/FilesHistoricConfigTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class FilesHistoricConfigTest {
3939
@BeforeEach
4040
void setup() {
4141
jimfs = Jimfs.newFileSystem(Configuration.unix());
42-
defaultRootPath = jimfs.getPath("/opt/hashgraph/blocknode/data/historic");
42+
defaultRootPath = jimfs.getPath("/opt/hiero/block-node/data/historic");
4343
defaultCompression = CompressionType.ZSTD;
4444
powersOfTenPerZipFileContents = 4;
4545
}

block-node/block-providers/files.recent/src/main/java/org/hiero/block/node/blocks/files/recent/FilesRecentConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
@ConfigData("files.recent")
2222
public record FilesRecentConfig(
23-
@Loggable @ConfigProperty(defaultValue = "/opt/hashgraph/blocknode/data/live") Path liveRootPath,
23+
@Loggable @ConfigProperty(defaultValue = "/opt/hiero/block-node/data/live") Path liveRootPath,
2424
@Loggable @ConfigProperty(defaultValue = "ZSTD") CompressionType compression,
2525
@Loggable @ConfigProperty(defaultValue = "3") int maxFilesPerDir) {
2626
/**

charts/block-node-server/README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ There are several ways to configure the Hiero Block Node. The following is the m
6565
1. Create an override values file, `values.yaml`:
6666
2. Add the necessary environment configuration variables to the following section:
6767

68-
```yaml
69-
blockNode:
70-
config:
71-
# Add any additional env configuration here
72-
# key: value
73-
BLOCKNODE_STORAGE_ROOT_PATH: "/app/storage"
68+
```yaml
69+
blockNode:
70+
config:
71+
# Add any additional env configuration here
72+
# key: value
73+
BLOCKNODE_STORAGE_ROOT_PATH: "/opt/hiero/block-node/storage"
74+
75+
```
7476

75-
```
7677
3. Secrets should be set at the following structure:
7778

7879
```yaml

charts/block-node-server/templates/deployment.yaml

+12-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ spec:
3333
- name: logging-config
3434
configMap:
3535
name: {{ include "hiero-block-node.fullname" . }}-logging-config
36+
- name: logging-storage
37+
persistentVolumeClaim:
38+
claimName: {{ if .Values.blockNode.persistence.logging.create }}{{ include "hiero-block-node.fullname" . }}-logging{{ else }}{{ .Values.blockNode.persistence.logging.existingClaim }}{{ end }}
3639
- name: archive-storage
3740
persistentVolumeClaim:
3841
claimName: {{ if .Values.blockNode.persistence.archive.create }}{{ include "hiero-block-node.fullname" . }}-archive{{ else }}{{ .Values.blockNode.persistence.archive.existingClaim }}{{ end }}
@@ -53,12 +56,17 @@ spec:
5356
chmod 700 /live-pvc/{{ .Values.blockNode.persistence.live.subPath }} && \
5457
mkdir -p /archive-pvc/{{ .Values.blockNode.persistence.archive.subPath }} && \
5558
chown 2000:2000 /archive-pvc/{{ .Values.blockNode.persistence.archive.subPath }} && \
56-
chmod 700 /archive-pvc/{{ .Values.blockNode.persistence.archive.subPath }}
59+
chmod 700 /archive-pvc/{{ .Values.blockNode.persistence.archive.subPath }} && \
60+
mkdir -p /logging-pvc/{{ .Values.blockNode.persistence.logging.subPath }} && \
61+
chown 2000:2000 /logging-pvc/{{ .Values.blockNode.persistence.logging.subPath }} && \
62+
chmod 700 /logging-pvc/{{ .Values.blockNode.persistence.logging.subPath }}
5763
volumeMounts:
5864
- name: live-storage
5965
mountPath: /live-pvc
6066
- name: archive-storage
6167
mountPath: /archive-pvc
68+
- name: logging-storage
69+
mountPath: /logging-pvc
6270
containers:
6371
- name: {{ .Chart.Name }}
6472
securityContext:
@@ -79,8 +87,10 @@ spec:
7987
name: {{ include "hiero-block-node.fullname" . }}-secret
8088
volumeMounts:
8189
- name: logging-config
82-
mountPath: /app/logs/config
90+
mountPath: {{ .Values.blockNode.logs.configMountPath }}
8391
readOnly: true
92+
- name: logging-storage
93+
mountPath: {{ .Values.blockNode.persistence.logging.mountPath }}
8494
- name: archive-storage
8595
mountPath: {{ .Values.blockNode.persistence.archive.mountPath }}
8696
subPath: {{ .Values.blockNode.persistence.archive.subPath }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if .Values.blockNode.persistence.logging.create }}
2+
apiVersion: v1
3+
kind: PersistentVolumeClaim
4+
metadata:
5+
name: {{ include "hiero-block-node.fullname" . }}-logging
6+
labels:
7+
{{- include "hiero-block-node.labels" . | nindent 4 }}
8+
spec:
9+
accessModes:
10+
- ReadWriteOnce
11+
resources:
12+
requests:
13+
storage: {{ .Values.blockNode.persistence.logging.size }}
14+
{{- if .Values.blockNode.persistence.logging.storageClass }}
15+
storageClassName: {{ .Values.blockNode.persistence.logging.storageClass }}
16+
{{- end }}
17+
{{- end }}

charts/block-node-server/values-overrides/mini.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ resources:
1111

1212
blockNode:
1313
config:
14-
JAVA_TOOL_OPTIONS: "-Djava.util.logging.config.file=/app/logs/config/logging.properties"
1514
JAVA_OPTS: "-Xms5G -Xmx5G"
1615
MEDIATOR_RING_BUFFER_SIZE: "2048"
1716
persistence:
1817
archive:
1918
size: 6Gi
2019
live:
2120
size: 1Gi
21+
logging:
22+
size: 1Gi
2223

2324
# Setting the PVC size for the Observability stack to mini claims of 1 Gigabyte
2425
kubepromstack:

charts/block-node-server/values.yaml

+18-5
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ blockNode:
7373
config:
7474
# Add any additional env configuration here
7575
# key: value
76-
JAVA_TOOL_OPTIONS: "-Djava.util.logging.config.file=/app/logs/config/logging.properties"
76+
JAVA_TOOL_OPTIONS: "-Djava.util.logging.config.file=/opt/hiero/block-node/logs/config/logging.properties"
7777
JAVA_OPTS: "-Xms16G -Xmx16G"
7878
# PRODUCER_TYPE: "NO_OP"
7979
# PERSISTENCE_STORAGE_TYPE: "NO_OP"
@@ -90,10 +90,22 @@ blockNode:
9090
subPath: "archive-data"
9191
# If create is true, the following values are used to create the PVC
9292
# should match PERSISTENCE_STORAGE_ARCHIVE_ROOT_PATH, leave as is for default.
93-
mountPath: "/opt/hashgraph/blocknode/data/historic"
93+
mountPath: "/opt/hiero/block-node/data/historic"
9494
size: 800Gi
9595
# Optionally add a storage class name if needed
9696
# storageClass: "your-storage-class"
97+
logging:
98+
# If false, the chart expects an externally provided PVC
99+
create: true
100+
# Name of the externally provided PVC
101+
existingClaim: ""
102+
# Name of the subPath in the PVC to mount to mountPath in the container
103+
subPath: "logging-data"
104+
# If create is true, the following values are used to create the PVC
105+
mountPath: "/opt/hiero/block-node/logs"
106+
size: 2Gi
107+
# Optionally add a storage class name if needed
108+
# storageClass: "your-storage-class"
97109
live:
98110
# If false, the chart expects an externally provided PVC
99111
create: true
@@ -103,15 +115,15 @@ blockNode:
103115
subPath: "live-data"
104116
# If create is true, the following values are used to create the PVC
105117
# should match PERSISTENCE_STORAGE_LIVE_ROOT_PATH, leave as is for default.
106-
mountPath: "/opt/hashgraph/blocknode/data/live"
118+
mountPath: "/opt/hiero/block-node/data/live"
107119
size: 20Gi
108120
# Optionally add a storage class name if needed
109121
# storageClass: "your-storage-class"
110122
unverified:
111123
# unverified does a hard-coded emptyDir and is ephemeral, however needs to be mounted
112124
# this does not create a PVC.
113125
# should match PERSISTENCE_STORAGE_UNVERIFIED_ROOT_PATH, leave as is for default.
114-
mountPath: "/opt/hashgraph/blocknode/data/unverified"
126+
mountPath: "/opt/hiero/block-node/data/unverified"
115127
secret:
116128
PRIVATE_KEY: "fake_private_key"
117129
health:
@@ -125,6 +137,7 @@ blockNode:
125137
# Available Levels are (from most verbose to least verbose):
126138
# ALL FINEST FINER FINE CONFIG INFO WARNING SEVERE OFF
127139
level: "INFO"
140+
configMountPath: "/opt/hiero/block-node/logs/config"
128141
loggingProperties:
129142
# com.hedera.block.server.producer.ProducerBlockItemObserver.level: "FINE"
130143
io.helidon.webserver.level: "INFO"
@@ -135,7 +148,7 @@ blockNode:
135148
handlers: "java.util.logging.ConsoleHandler, java.util.logging.FileHandler"
136149
java.util.logging.ConsoleHandler.level: "FINE"
137150
java.util.logging.ConsoleHandler.formatter: "java.util.logging.SimpleFormatter"
138-
java.util.logging.FileHandler.pattern: "/app/logs/blocknode-%g.log"
151+
java.util.logging.FileHandler.pattern: "/opt/hiero/block-node/logs/blocknode-%g.log"
139152
java.util.logging.FileHandler.append: "true"
140153
java.util.logging.FileHandler.limit: "5_000_000"
141154
java.util.logging.FileHandler.count: "5"

simulator/docker/Dockerfile

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,29 @@ FROM eclipse-temurin:21
44
ARG UNAME=hedera
55
ARG UID=2000
66
ARG GID=2000
7+
ARG BN_WORKDIR="/opt/hiero/block-node"
78
RUN groupadd --gid $GID $UNAME
89
RUN useradd --no-user-group --create-home --uid $UID --gid $GID --shell /bin/bash hedera
9-
WORKDIR /app
10+
WORKDIR ${BN_WORKDIR}
1011

1112
# Copy the distribution and resources
1213
COPY simulator-*.tar ./simulator.tar
1314

14-
RUN mkdir -p /app/logs/config
15-
COPY logging.properties /app/logs/config/logging.properties
15+
RUN mkdir -p ${BN_WORKDIR}/logs/config
16+
COPY logging.properties ${BN_WORKDIR}/logs/config/logging.properties
1617

1718
# Extract the distribution and block data
1819
RUN tar -xf simulator.tar && \
1920
rm simulator.tar && \
20-
cd /app && \
21-
chown -R $UID:$GID /app
21+
cd ${BN_WORKDIR} && \
22+
chown -R $UID:$GID ${BN_WORKDIR}
2223

2324
# Switch to non-root user
2425
USER $UNAME
2526

2627
# Run the simulator using the extracted directory name
2728
RUN SIMULATOR_DIR=$(ls -d simulator-*/) && \
28-
echo "#!/bin/bash\n/app/${SIMULATOR_DIR}bin/simulator" > /app/start.sh && \
29-
chmod +x /app/start.sh
29+
echo "#!/bin/bash\n${BN_WORKDIR}/${SIMULATOR_DIR}bin/simulator" > ${BN_WORKDIR}/start.sh && \
30+
chmod +x ${BN_WORKDIR}/start.sh
3031

31-
ENTRYPOINT ["/app/start.sh"]
32+
ENTRYPOINT ["${BN_WORKDIR}/start.sh"]

simulator/docker/update-env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ CONSUMER_BLOCK_STREAM_SIMULATOR_MODE=CONSUMER
1919
CONSUMER_PROMETHEUS_ENDPOINT_PORT_NUMBER=9997
2020
EOL
2121

22-
logging_config_file_arg="-Djava.util.logging.config.file=/app/logs/config/logging.properties"
22+
logging_config_file_arg="-Djava.util.logging.config.file=/opt/hiero/block-node/logs/config/logging.properties"
2323
debug_arg="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5006"
2424
# determine if we should include debug opts
2525
[ "$1" = true ] && is_debug=true || is_debug=false

simulator/src/main/resources/logging.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
3636
# FileHandler properties
3737
################################################################################
3838
# The pattern for the output file name.
39-
java.util.logging.FileHandler.pattern = /app/logs/blocknode-%g.log
39+
java.util.logging.FileHandler.pattern = /opt/hiero/block-node/logs/blocknode-%g.log
4040
# Set append to true if you want to keep appending to existing files
4141
java.util.logging.FileHandler.append = true
4242
# The limit in bytes before a new file is started.

suites/src/main/java/org/hiero/block/suites/persistence/positive/PositiveDataPersistenceTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
@DisplayName("Positive Data Persistence Tests")
2424
public class PositiveDataPersistenceTests extends BaseSuite {
2525
private final String[] GET_BLOCKS_COMMAND =
26-
new String[] {"find", "../opt/hashgraph/blocknode/data/live", "-mindepth", "5", "-maxdepth", "7"};
26+
new String[] {"find", "/opt/hiero/block-node/data/live", "-mindepth", "5", "-maxdepth", "7"};
2727

2828
private Future<?> simulatorThread;
2929

0 commit comments

Comments
 (0)