Skip to content

Instantly share code, notes, and snippets.

@miklosbagi
Last active May 21, 2024 16:22
Show Gist options
  • Save miklosbagi/690735c2c0c6b15e3f9f3850d578d724 to your computer and use it in GitHub Desktop.
Save miklosbagi/690735c2c0c6b15e3f9f3850d578d724 to your computer and use it in GitHub Desktop.
docker-compose-nexus
networks:
nexus:
services:
# pre container is used to set the correct permissions on the nexus-data and config dirs
pre:
image: alpine:3.19
volumes:
- ./data:/data
- ./config:/config
command: sh -c 'mkdir -p /data/nexus /config/nexus && chown -R 200:200 /data/nexus && chown -R 200:200 /config/nexus'
postgres:
image: postgres:16.1-alpine3.18
environment:
- POSTGRES_USER=nexus
- POSTGRES_PASSWORD=nexus
- POSTGRES_DB=nexus
volumes:
- ./data/postgres:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "nexus"]
interval: 30s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- nexus
nexus:
image: sonatype/nexus3:3.63.0
ports:
- "8081:8081"
volumes:
# note: nexus-data and config dirs needs to be owned by user:group 200:200, see `pre` container
- ./data/nexus:/nexus-data
- ./config/nexus:/opt/sonatype/nexus/etc
environment:
- INSTALL4J_ADD_VM_PARAMS=-Xms256m -Xmx512m -XX:MaxDirectMemorySize=1g -Djava.util.prefs.userRoot=/nexus-data/javaprefs
- NEXUS_SECURITY_RANDOMPASSWORD=false
- NEXUS_SECURITY_REALM=Database
- NEXUS_SECURITY_AUTHENTICATION_REALMS=Database
- NEXUS_SECURITY_SOURCE_REALM=Database
- NEXUS_SECURITY_AUTHORIZATION_REALMS=Database
- NEXUS_SECURITY_ROLE_SOURCE=Database
depends_on:
pre:
condition: service_completed_successfully
postgres:
condition: service_healthy
restart: unless-stopped
mem_limit: 1g
cpus: '1'
networks:
- nexus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment