Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Templating] Set virtualhost from an env variable
  • Loading branch information
mgrzybek committed Sep 27, 2019
commit e80ddf2803a584d77366b1807e5b39451e6ac0c2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker-compose.yml
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,22 @@ prepare:
nexus/Dockerfile.tmpl > nexus/Dockerfile \
|| true

# docker-compose: Set traefik virtualhost
@test -z ${TRAEFIK_VIRTUALHOST} \
&& sed "s/%%TRAEFIK_VIRTUALHOST%%/localhost/" \
docker-compose.yml.tmpl > docker-compose.yml \
|| sed "s/%%TRAEFIK_VIRTUALHOST%%/${TRAEFIK_VIRTUALHOST}/" \
docker-compose.yml.tmpl > docker-compose.yml

.PHONY: clean # Stop and remove temporary files
clean: down
@docker-compose rm

@rm -f \
jenkins/Dockerfile \
nexus/Dockerfile \
sonar/Dockerfile

@docker-compose rm
sonar/Dockerfile \
docker-compose.yml

##############################################################################

Expand Down
99 changes: 99 additions & 0 deletions docker-compose.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
version: '3'

networks:
prodnetwork:
driver: bridge

volumes:
nexus-data:
jenkins-data:

services:
traefik:
image: traefik:montdor
restart: always
command: --accesslog --api --api.insecure=true --log --providers.docker=true --providers.docker.exposedbydefault=false
ports:
- "80:80"
- "443:443"
- "8080:8080"
networks:
- prodnetwork
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
nexus:
# Nexus3 uses chef-solo. HTTP_PROXY env is not used.
# TODO: deal with Nexus3 and proxies.
build: ./nexus
restart: always
networks:
- prodnetwork
volumes:
- nexus-data:/nexus-data
labels:
- "traefik.enable=true"
- "traefik.http.routers.nexus.rule=Host(`%%TRAEFIK_VIRTUALHOST%%`) && PathPrefix(`/nexus/`)"
jenkins:
build: ./jenkins
restart: always
networks:
- prodnetwork
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- jenkins-data:/var/lib/jenkins/
depends_on:
- nexus
- sonar
environment:
- NEXUS_PORT=8081
- SONAR_PORT=9000
- SONAR_DB_PORT=5432
- JENKINS_OPTS=--prefix=/jenkins/
labels:
- "traefik.enable=true"
- "traefik.http.routers.jenkins.rule=Host(`%%TRAEFIK_VIRTUALHOST%%`) && PathPrefix(`/jenkins`)"
sonardb:
networks:
- prodnetwork
restart: always
image: postgres:9.6
environment:
- POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar
sonar:
image: sonarqube
restart: always
networks:
- prodnetwork
depends_on:
- sonardb
environment:
- SONARQUBE_JDBC_URL=jdbc:postgresql://sonardb:5432/sonar
- SONARQUBE_JDBC_USERNAME=sonar
- SONARQUBE_JDBC_PASSWORD=sonar
- sonar.web.context=/sonar
labels:
- "traefik.enable=true"
- "traefik.http.routers.sonar.rule=Host(`%%TRAEFIK_VIRTUALHOST%%`) && PathPrefix(`/sonar/`)"

##########################################################################################
# DISABLED: GitLab takes too much memory and CPU. Demo uses GitHub repositories instead.
#
# gitlab:
# image: gitlab/gitlab-ce:latest
# restart: always
# networks:
# - prodnetwork
# environment:
# GITLAB_OMNIBUS_CONFIG: |
# # external_url 'https://gitlab.example.com'
# # Add any other gitlab.rb configuration here, each on its own line
# ports:
# - "10080:80"
# - "10443:443"
# - "10022:22"
# volumes:
# - /opt/gitlab/config:/etc/gitlab
# - /opt/gitlab/logs:/var/log/gitlab
# - /opt/gitlab/data:/var/opt/gitlab