Skip to content

Commit 0ff3244

Browse files
authored
Merge pull request #38 from sonatype-nexus-community/feat/use-docker-volumes
feat: use docker volumes & nxrm pro to use PostgreSQL
2 parents 0f15133 + ad0697b commit 0ff3244

File tree

2 files changed

+76
-48
lines changed

2 files changed

+76
-48
lines changed

config/nexus-iq-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ server:
6969
- type: file
7070

7171
# The file to which current statements will be logged.
72-
currentLogFilename: ./log/request.log
72+
currentLogFilename: /var/log/nexus-iq-server/request.log
7373

7474
logFormat: '%clientHost %l %user [%date] "%requestURL" %statusCode %bytesSent %elapsedTime "%header{User-Agent}"'
7575

7676
# When the log file rotates, the archived log will be renamed to this and gzipped. The
7777
# %d is replaced with the previous day (yyyy-MM-dd). Custom rolling windows can be created
7878
# by passing a SimpleDateFormat-compatible format as an argument: "%d{yyyy-MM-dd-hh}".
79-
archivedLogFilenamePattern: ./log/request-%d.log.gz
79+
archivedLogFilenamePattern: /var/log/nexus-iq-server/request-%d.log.gz
8080

8181
# The number of archived files to keep.
8282
archivedFileCount: 5
@@ -162,26 +162,26 @@ logging:
162162
appenders:
163163
- type: file
164164
# The file to which audit statements will be logged.
165-
currentLogFilename: ./log/audit.log
165+
currentLogFilename: /var/log/nexus-iq-server/audit.log
166166
# When the audit log file rotates, the archived audit log will be renamed to this and gzipped. The
167167
# %d is replaced with the previous day (yyyy-MM-dd). Custom rolling windows can be created
168168
# by passing a SimpleDateFormat-compatible format as an argument: "%d{yyyy-MM-dd-hh}".
169169
#
170170
# If archive is true, this must be specified.
171-
archivedLogFilenamePattern: ./log/audit-%d.log.gz
171+
archivedLogFilenamePattern: /var/log/nexus-iq-server/audit-%d.log.gz
172172
# The number of archived audit log files to keep.
173173
archivedFileCount: 5
174174
"com.sonatype.insight.policy.violation":
175175
appenders:
176176
- type: file
177177
# The file to which policy violations will be logged.
178-
currentLogFilename: ./log/policy-violation.log
178+
currentLogFilename: /var/log/nexus-iq-server/policy-violation.log
179179
# When the policy violation log file rotates, the archived policy violation log will be renamed to this
180180
# and gzipped. The %d is replaced with the previous day (yyyy-MM-dd). Custom rolling windows can be created
181181
# by passing a SimpleDateFormat-compatible format as an argument: "%d{yyyy-MM-dd-hh}".
182182
#
183183
# If archive is true, this must be specified.
184-
archivedLogFilenamePattern: ./log/policy-violation-%d.log.gz
184+
archivedLogFilenamePattern: /var/log/nexus-iq-server/policy-violation-%d.log.gz
185185
# The number of archived policy violation log files to keep.
186186
archivedFileCount: 5
187187

@@ -203,14 +203,14 @@ logging:
203203
logFormat: "%d{'yyyy-MM-dd HH:mm:ss,SSSZ'} %level [%thread] %X{username} %logger - %msg%n"
204204

205205
# The file to which current statements will be logged.
206-
currentLogFilename: ./log/clm-server.log
206+
currentLogFilename: /var/log/nexus-iq-server/clm-server.log
207207

208208
# When the log file rotates, the archived log will be renamed to this and gzipped. The
209209
# %d is replaced with the previous day (yyyy-MM-dd). Custom rolling windows can be created
210210
# by passing a SimpleDateFormat-compatible format as an argument: "%d{yyyy-MM-dd-hh}".
211211
#
212212
# If archive is true, this must be specified.
213-
archivedLogFilenamePattern: ./log/clm-server-%d.log.gz
213+
archivedLogFilenamePattern: /var/log/nexus-iq-server/clm-server-%d.log.gz
214214

215215
# The number of archived files to keep.
216216
archivedFileCount: 5

docker-compose.yml

Lines changed: 68 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: '3.9'
22

3-
x-env-license: &env-license-volume '${NEXUS_LICENSE_PATH:?err}:/sonatype-license.lic'
3+
x-env-license: &env-license-volume '${NEXUS_LICENSE_PATH:?err}:/sonatype-license.lic:ro'
44

55
x-nxrm3-healthcheck: &nxrm3-healthcheck
66
test:
@@ -16,15 +16,21 @@ x-nxrm3-healthcheck: &nxrm3-healthcheck
1616
retries: 10
1717
start_period: 40s
1818

19+
x-nxiq-volume-data: &x-nxiq-volume-data 'nxiq-data:/sonatype-work'
20+
21+
x-nxiq-volume-logs: &x-nxiq-volume-logs 'nxiq-logs:/var/log/nexus-iq-server'
22+
1923
x-nxrm3-volume-nexus-properties: &nxrm3-volume-nexus-properties './config/nexus-repo.properties:/nexus-data/etc/nexus.properties'
2024

2125
x-nxrm3-volume-casc-config: &nxrm3-volume-casc-config './config/nexus-repo-casc.yaml:/opt/nexus.yml:ro'
2226

2327
x-nxrm3-volume-casc-config-oss: &nxrm3-volume-casc-config-oss './config/nexus-repo-casc-oss.yaml:/opt/nexus.yml:ro'
2428

25-
x-nxrm3-volume-data: &nxrm3-volume-data '${DOCKER_ROOT_VOLUME_MOUNT_POINT:?err}/nexus-data:/nexus-data:delegated'
29+
x-nxrm3-volume-data: &nxrm3-volume-data 'nxrm-data:/opt/sonatype/sonatype-work'
30+
31+
x-pgsql-volume-data: &pgsql-volume-data 'pg-data:/var/lib/postgresql/data'
2632

27-
x-pgsql-volume-data: &pgsql-volume-data '${DOCKER_ROOT_VOLUME_MOUNT_POINT:?err}/pgdata:/var/lib/postgresql/data/pgdata:delegated'
33+
x-pgsql-nxrm-volume-data: &pgsql-nxrm-volume-data 'pg-nxrm-data:/var/lib/postgresql/data'
2834

2935

3036
secrets:
@@ -33,8 +39,11 @@ secrets:
3339

3440
services:
3541

36-
nxiq_direct:
42+
nxiq-direct:
3743
image: "${NEXUS_DOCKER_IMAGE_ORGANIZATION}/nexus-iq-server:${NEXUS_IQ_SERVER_VERSION:?err}"
44+
depends_on:
45+
postgres:
46+
condition: service_healthy
3847
environment:
3948
JAVA_OPTS: "-Ddw.baseUrl=${NXLC_FQDN_URL:-http://iq.localhost:8070} -Djava.util.prefs.userRoot=/sonatype-work/javaprefs"
4049
DATABASE_TYPE: postgresql
@@ -53,14 +62,14 @@ services:
5362
volumes:
5463
- *env-license-volume
5564
- "./config/nexus-iq-config.yaml:/etc/nexus-iq-server/config.yml:delegated"
56-
- "${DOCKER_ROOT_VOLUME_MOUNT_POINT:?err}/iq-data:/sonatype-work:delegated"
57-
- "${DOCKER_ROOT_VOLUME_MOUNT_POINT:?err}/iq-logs:/opt/sonatype/nexus-iq-server/log:delegated"
65+
- *x-nxiq-volume-data
66+
- *x-nxiq-volume-logs
67+
68+
nxiq-proxied:
69+
image: "${NEXUS_DOCKER_IMAGE_ORGANIZATION}/nexus-iq-server:${NEXUS_IQ_SERVER_VERSION:?err}"
5870
depends_on:
5971
postgres:
6072
condition: service_healthy
61-
62-
nxiq-proxied:
63-
image: "${NEXUS_DOCKER_IMAGE_ORGANIZATION}/nexus-iq-server:${NEXUS_IQ_SERVER_VERSION:?err}"
6473
environment:
6574
JAVA_OPTS: "-Ddw.baseUrl=${NXLC_FQDN_URL:-http://iq.localhost} -Djava.util.prefs.userRoot=/sonatype-work/javaprefs"
6675
DATABASE_TYPE: postgresql
@@ -80,18 +89,19 @@ services:
8089
volumes:
8190
- *env-license-volume
8291
- "./config/nexus-iq-config.yaml:/etc/nexus-iq-server/config.yml:delegated"
83-
- "${DOCKER_ROOT_VOLUME_MOUNT_POINT:?err}/iq-data:/sonatype-work:delegated"
84-
- "${DOCKER_ROOT_VOLUME_MOUNT_POINT:?err}/iq-logs:/opt/sonatype/nexus-iq-server/log:delegated"
85-
depends_on:
86-
postgres:
87-
condition: service_healthy
92+
- *x-nxiq-volume-data
93+
- *x-nxiq-volume-logs
8894

89-
nxrm3_direct:
95+
nxrm3-direct:
9096
image: "${NEXUS_DOCKER_IMAGE_ORGANIZATION}/nexus3:${NEXUS_REPOSITORY_VERSION:?err}"
97+
depends_on:
98+
postgres-nxrm:
99+
condition: service_healthy
91100
environment:
92101
BASE_URL: "${NXRM_FQDN_URL:-http://repo.localhost:8081}"
102+
DATABASE_PASSWORD: ${PG_DB_PASS:?err}
103+
INSTALL4J_ADD_VM_PARAMS: "-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Dnexus.licenseFile=/sonatype-license.lic -Dnexus.datastore.enabled=true -Djava.util.prefs.userRoot=$${NEXUS_DATA}/javaprefs -Dnexus.datastore.nexus.jdbcUrl=jdbc:postgresql://postgres-nxrm:5432/nxrm -Dnexus.datastore.nexus.username=nxrm -Dnexus.datastore.nexus.password=$${DATABASE_PASSWORD} -Dnexus.datastore.clustered.enabled=true"
93104
NEXUS_SECURITY_RANDOMPASSWORD: 'false'
94-
NEXUS_CASC_CONFIG: '/opt/nexus.yml'
95105
NEXUS_IQ_BASE_URL: "${NXLC_FQDN_URL:-http://iq.localhost:8070}"
96106
healthcheck:
97107
<<: *nxrm3-healthcheck
@@ -104,17 +114,9 @@ services:
104114
- admin_password
105115
volumes:
106116
- *env-license-volume
107-
- *nxrm3-volume-nexus-properties
108-
- *nxrm3-volume-casc-config
109-
- *nxrm3-volume-data
110117

111118
nxrm3_direct_oss:
112-
build:
113-
context: ./images/nxrm3
114-
args:
115-
NEXUS_DOCKER_IMAGE_ORGANIZATION: "${NEXUS_DOCKER_IMAGE_ORGANIZATION}"
116-
NEXUS_REPOSITORY_VERSION: "${NEXUS_REPOSITORY_VERSION}"
117-
NEXUS_CASC_PLUGIN_VERSION: "${NEXUS_CASC_PLUGIN_VERSION}"
119+
image: "${NEXUS_DOCKER_IMAGE_ORGANIZATION}/nexus3:${NEXUS_REPOSITORY_VERSION:?err}"
118120
environment:
119121
BASE_URL: 'http://repo.localhost:8081'
120122
NEXUS_SECURITY_RANDOMPASSWORD: 'false'
@@ -128,22 +130,21 @@ services:
128130
- repoOssDemo
129131
secrets:
130132
- admin_password
131-
volumes:
132-
- *nxrm3-volume-nexus-properties
133-
- *nxrm3-volume-casc-config-oss
134-
- *nxrm3-volume-data
133+
# volumes:
134+
# - *nxrm3-volume-nexus-properties
135+
# - *nxrm3-volume-casc-config-oss
136+
# - *nxrm3-volume-data
135137

136138
nxrm3-proxied:
137-
build:
138-
context: ./images/nxrm3
139-
args:
140-
NEXUS_DOCKER_IMAGE_ORGANIZATION: "${NEXUS_DOCKER_IMAGE_ORGANIZATION}"
141-
NEXUS_REPOSITORY_VERSION: "${NEXUS_REPOSITORY_VERSION}"
142-
NEXUS_CASC_PLUGIN_VERSION: "${NEXUS_CASC_PLUGIN_VERSION}"
139+
image: "${NEXUS_DOCKER_IMAGE_ORGANIZATION}/nexus3:${NEXUS_REPOSITORY_VERSION:?err}"
140+
depends_on:
141+
postgres-nxrm:
142+
condition: service_healthy
143143
environment:
144-
BASE_URL: "${NXRM_FQDN_URL:-http://repo.localhost}"
144+
BASE_URL: "${NXRM_FQDN_URL:-http://repo.localhost}"
145+
DATABASE_PASSWORD: ${PG_DB_PASS:?err}
146+
INSTALL4J_ADD_VM_PARAMS: "-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Dnexus.licenseFile=/sonatype-license.lic -Dnexus.datastore.enabled=true -Djava.util.prefs.userRoot=$${NEXUS_DATA}/javaprefs -Dnexus.datastore.nexus.jdbcUrl=jdbc:postgresql://postgres-nxrm:5432/nxrm -Dnexus.datastore.nexus.username=nxrm -Dnexus.datastore.nexus.password=$${DATABASE_PASSWORD} -Dnexus.datastore.clustered.enabled=true"
145147
NEXUS_SECURITY_RANDOMPASSWORD: 'false'
146-
NEXUS_CASC_CONFIG: '/opt/nexus.yml'
147148
NEXUS_IQ_BASE_URL: "${NXLC_FQDN_URL:-http://iq.localhost}"
148149
healthcheck:
149150
<<: *nxrm3-healthcheck
@@ -159,9 +160,6 @@ services:
159160
- admin_password
160161
volumes:
161162
- *env-license-volume
162-
- *nxrm3-volume-nexus-properties
163-
- *nxrm3-volume-casc-config
164-
- *nxrm3-volume-data
165163

166164
postgres:
167165
image: "postgres:16.0-alpine3.18"
@@ -175,6 +173,7 @@ services:
175173
- platform
176174
ports:
177175
- '5432:5432'
176+
shm_size: 128mb
178177
user: '${UID}:${GID}'
179178
volumes:
180179
- *pgsql-volume-data
@@ -184,6 +183,28 @@ services:
184183
timeout: 5s
185184
retries: 10
186185

186+
postgres-nxrm:
187+
image: "postgres:16.0-alpine3.18"
188+
environment:
189+
- POSTGRES_USER=nxrm
190+
- POSTGRES_PASSWORD=${PG_DB_PASS:?err}
191+
- POSTGRES_DB=nxrm
192+
- PGDATA=/var/lib/postgresql/data/pgdata
193+
networks:
194+
- default
195+
- platform
196+
ports:
197+
- '5433:5432'
198+
shm_size: 128mb
199+
user: '${UID}:${GID}'
200+
volumes:
201+
- *pgsql-nxrm-volume-data
202+
healthcheck:
203+
test: ["CMD-SHELL", "pg_isready -U nxrm"]
204+
interval: 1s
205+
timeout: 5s
206+
retries: 10
207+
187208
proxy:
188209
image: "nginx:${NGINX_VERSION:?err}"
189210
depends_on:
@@ -397,3 +418,10 @@ networks:
397418
default: null
398419
platform: null
399420
teamcity: null
421+
422+
volumes:
423+
nxiq-data:
424+
nxiq-logs:
425+
nxrm-data:
426+
pg-data:
427+
pg-nxrm-data:

0 commit comments

Comments
 (0)