Skip to content

Commit 45d6f64

Browse files
committed
feat(docker-compose): add docker-compose scripts and services for development environment
1 parent 62682cc commit 45d6f64

16 files changed

+526
-0
lines changed

.gitattributes

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Set default behavior to automatically normalize line endings.
2+
* text=auto
3+
4+
# Collapse these files in PRs by default
5+
*.xlf linguist-generated=true
6+
*.lcl linguist-generated=true
7+
8+
*.jpg binary
9+
*.png binary
10+
*.gif binary
11+
12+
# Force bash scripts to always use lf line endings so that if a repo is accessed
13+
# in Unix via a file share from Windows, the scripts will work.
14+
*.in text eol=lf
15+
*.sh text eol=lf
16+
17+
# Likewise, force cmd and batch scripts to always use crlf
18+
*.cmd text eol=crlf
19+
*.bat text eol=crlf
20+
21+
*.cs text=auto diff=csharp
22+
*.vb text=auto
23+
*.resx text=auto
24+
*.c text=auto
25+
*.cpp text=auto
26+
*.cxx text=auto
27+
*.h text=auto
28+
*.hxx text=auto
29+
*.py text=auto
30+
*.rb text=auto
31+
*.java text=auto
32+
*.html text=auto
33+
*.htm text=auto
34+
*.css text=auto
35+
*.scss text=auto
36+
*.sass text=auto
37+
*.less text=auto
38+
*.js text=auto
39+
*.lisp text=auto
40+
*.clj text=auto
41+
*.sql text=auto
42+
*.php text=auto
43+
*.lua text=auto
44+
*.m text=auto
45+
*.asm text=auto
46+
*.erl text=auto
47+
*.fs text=auto
48+
*.fsx text=auto
49+
*.hs text=auto
50+
51+
*.csproj text=auto
52+
*.vbproj text=auto
53+
*.fsproj text=auto
54+
*.dbproj text=auto
55+
*.sln text=auto eol=crlf
56+
57+
# Set linguist language for .h files explicitly based on
58+
# https://github.com/github/linguist/issues/1626#issuecomment-401442069
59+
# this only affects the repo's language statistics
60+
*.h linguist-language=C

src/docker-compose/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
COMPOSE_PROJECT_NAME=localenv
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services: {}
2+
3+
networks:
4+
default:
5+
name: localenv

src/docker-compose/localenv.ps1

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
param(
2+
[Parameter(Position=0)]
3+
[ValidateSet("up", "down")]
4+
[string] $Command = "up",
5+
6+
[Parameter(Position=1)]
7+
[Alias("f")]
8+
[string[]] $OverrideFiles,
9+
10+
[Parameter(Position=2)]
11+
[string[]] $profiles = @("full"),
12+
13+
[Alias("v")]
14+
[switch] $RemoveVolumes
15+
)
16+
17+
$composeFileArgs = @()
18+
$composeFileArgs += "compose"
19+
$composeFileArgs += "-f"
20+
$composeFileArgs += "docker-compose.yaml"
21+
22+
$composeFiles = Get-ChildItem -Path . -Filter *.docker-compose.yaml -Recurse | ForEach-Object { $_.FullName }
23+
foreach ($file in $composeFiles) {
24+
$composeFileArgs += "-f"
25+
$composeFileArgs += "`"$file`""
26+
}
27+
28+
if ($OverrideFiles) {
29+
foreach ($overrideFile in $OverrideFiles) {
30+
$composeFileArgs += "-f"
31+
$composeFileArgs += "`"$overrideFile`""
32+
}
33+
}
34+
35+
# Add profiles
36+
if ($profiles) {
37+
foreach ($profile in $profiles) {
38+
$composeFileArgs += "--profile"
39+
$composeFileArgs += $profile
40+
}
41+
}
42+
43+
# Add common docker-compose options
44+
$composeFileArgs += "--ansi"
45+
$composeFileArgs += "never"
46+
47+
if ($Command -eq "down") {
48+
$composeFileArgs += "down"
49+
$composeFileArgs += "--remove-orphans"
50+
if ($RemoveVolumes) {
51+
$composeFileArgs += "--volumes"
52+
}
53+
}
54+
else {
55+
$composeFileArgs += "up"
56+
$composeFileArgs += "-d"
57+
$composeFileArgs += "--build"
58+
$composeFileArgs += "--force-recreate"
59+
$composeFileArgs += "--remove-orphans"
60+
}
61+
62+
Start-Process -FilePath "docker" -ArgumentList $composeFileArgs -NoNewWindow -Wait
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
services:
2+
azurite:
3+
image: mcr.microsoft.com/azure-storage/azurite
4+
container_name: azurite.localenv.io
5+
profiles: [full, azurite]
6+
restart: unless-stopped
7+
command: 'azurite -l /data -d /data/debug.log --blobHost azurite.localenv.io --queueHost azurite.localenv.io --tableHost azurite.localenv.io --loose --disableProductStyleUrl'
8+
deploy:
9+
resources:
10+
limits:
11+
memory: 512M
12+
ports:
13+
- "10000:10000" # Blob service
14+
- "10001:10001" # Queue service
15+
- "10002:10002" # Table service
16+
networks:
17+
default:
18+
aliases:
19+
- azurite.localenv.io
20+
volumes:
21+
- azurite_data:/data
22+
labels:
23+
# - "traefik.enable=true"
24+
# - "traefik.http.routers.azurite-blob.rule=Host(`blob.azurite.localenv.io`)"
25+
# - "traefik.http.routers.azurite-blob.entrypoints=websecure"
26+
# - "traefik.http.routers.azurite-blob.service=azurite-blob"
27+
# - "traefik.http.services.azurite-blob.loadbalancer.server.port=10000"
28+
29+
# - "traefik.http.routers.azurite-queue.rule=Host(`queue.azurite.localenv.io`)"
30+
# - "traefik.http.routers.azurite-queue.entrypoints=websecure"
31+
# - "traefik.http.routers.azurite-queue.service=azurite-queue"
32+
# - "traefik.http.services.azurite-queue.loadbalancer.server.port=10001"
33+
34+
# - "traefik.http.routers.azurite-table.rule=Host(`table.azurite.localenv.io`)"
35+
# - "traefik.http.routers.azurite-table.entrypoints=websecure"
36+
# - "traefik.http.routers.azurite-table.service=azurite-table"
37+
# - "traefik.http.services.azurite-table.loadbalancer.server.port=10002"
38+
39+
- com.centurylinklabs.watchtower.enable=true
40+
41+
42+
volumes:
43+
azurite_data:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
services:
2+
mssql:
3+
image: mcr.microsoft.com/mssql/server:2022-latest
4+
# image: mcr.microsoft.com/azure-sql-edge:latest
5+
profiles: [full, mssql]
6+
container_name: mssql.localenv.io
7+
restart: unless-stopped
8+
deploy:
9+
resources:
10+
limits:
11+
memory: 2G
12+
ports:
13+
- "1433:1433"
14+
networks:
15+
default:
16+
aliases:
17+
- mssql.localenv.io
18+
environment:
19+
- ACCEPT_EULA=Y
20+
- TZ=Europe/Bucharest
21+
- MSSQL_SA_PASSWORD=SuperPass#
22+
volumes:
23+
- mssql_data:/var/opt/mssql
24+
healthcheck:
25+
test: ["CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P $${MSSQL_SA_PASSWORD} -Q 'SELECT @@VERSION'"]
26+
interval: 30s
27+
timeout: 10s
28+
retries: 3
29+
start_period: 30s
30+
31+
32+
volumes:
33+
mssql_data:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
services:
2+
ngrok:
3+
image: "ngrok/ngrok:latest"
4+
container_name: ngrok.localenv.io
5+
profiles: [full, ngrok]
6+
restart: unless-stopped
7+
deploy:
8+
resources:
9+
limits:
10+
memory: 128M
11+
environment:
12+
NGROK_AUTHTOKEN: ${NGROK_AUTHTOKEN}
13+
command:
14+
- "http"
15+
- "http://host.docker.internal:80"
16+
ports:
17+
- 4040:4040
18+
networks:
19+
default:
20+
aliases:
21+
- ngrok.localenv.io
22+
labels:
23+
- "traefik.enable=true"
24+
- "traefik.http.routers.ngrok.rule=Host(`ngrok.localenv.io`)"
25+
- "traefik.http.routers.ngrok.entrypoints=web"
26+
- "traefik.http.services.ngrok.loadbalancer.server.port=4040"
27+
- com.centurylinklabs.watchtower.enable=true
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
postgres:
3+
image: postgres:latest
4+
container_name: postgres.localenv.io
5+
profiles: [full, postgres]
6+
restart: unless-stopped
7+
deploy:
8+
resources:
9+
limits:
10+
memory: 768M
11+
environment:
12+
POSTGRES_PASSWORD: SuperPass#
13+
ports:
14+
- 5432:5432
15+
networks:
16+
default:
17+
aliases:
18+
- postgres.localenv.io
19+
volumes:
20+
- postgres_data:/var/lib/postgresql/data
21+
healthcheck:
22+
test: ["CMD-SHELL", "pg_isready", "-d", "db_prod"]
23+
interval: 30s
24+
timeout: 60s
25+
retries: 5
26+
start_period: 80s
27+
labels:
28+
- com.centurylinklabs.watchtower.enable=true
29+
30+
volumes:
31+
postgres_data:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"users": [
3+
{
4+
"name": "admin",
5+
"password_hash": "7rmMIKY4A4wXVTfI0AJt1kjL4LN2vElhsiml+NFkY/z+IpSX",
6+
"hashing_algorithm": "rabbit_password_hashing_sha256",
7+
"tags": "administrator"
8+
},
9+
{
10+
"name": "localenv",
11+
"password_hash": "I0XZ4d1GJ7bTTeI+nS0iROlf2ZmUVlYZ01Me+p5NxEen2eRw",
12+
"hashing_algorithm": "rabbit_password_hashing_sha256",
13+
"tags": ""
14+
}
15+
],
16+
"vhosts": [
17+
{
18+
"name": "localenv"
19+
},
20+
{
21+
"name": "\/"
22+
}
23+
],
24+
"permissions": [
25+
{
26+
"user": "admin",
27+
"vhost": "\/",
28+
"configure": ".*",
29+
"write": ".*",
30+
"read": ".*"
31+
},
32+
{
33+
"user": "admin",
34+
"vhost": "localenv",
35+
"configure": ".*",
36+
"write": ".*",
37+
"read": ".*"
38+
},
39+
{
40+
"user": "localenv",
41+
"vhost": "localenv",
42+
"configure": ".*",
43+
"write": ".*",
44+
"read": ".*"
45+
}
46+
],
47+
"parameters": [],
48+
"policies": [],
49+
"queues": [],
50+
"exchanges": [],
51+
"bindings": []
52+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
loopback_users.guest = false
2+
management.load_definitions = /etc/rabbitmq/definitions.json
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
services:
2+
rabbitmq:
3+
image: rabbitmq:3-management
4+
container_name: rabbitmq.localenv.io
5+
profiles: [full, rabbitmq]
6+
restart: unless-stopped
7+
deploy:
8+
resources:
9+
limits:
10+
memory: 1G
11+
environment:
12+
RABBITMQ_ERLANG_COOKIE: "9sSrGRLmjcTm5dTg"
13+
RABBITMQ_HEALTHCHECK_USER: admin
14+
RABBITMQ_HEALTHCHECK_PASS: SuperPass#
15+
ports:
16+
- 5672:5672
17+
- 5671:5671
18+
networks:
19+
default:
20+
aliases:
21+
- rabbitmq.localenv.io
22+
volumes:
23+
- ./services/rabbitmq/config/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
24+
- ./services/rabbitmq/config/definitions.json:/etc/rabbitmq/definitions.json
25+
- rabbitmq_data:/var/lib/rabbitmq
26+
labels:
27+
- "traefik.enable=true"
28+
- "traefik.http.routers.rabbitmq.rule=Host(`rabbitmq.localenv.io`)"
29+
- "traefik.http.routers.rabbitmq.entrypoints=web"
30+
- "traefik.http.services.rabbitmq.loadbalancer.server.port=15672"
31+
- com.centurylinklabs.watchtower.enable=true
32+
healthcheck:
33+
test: rabbitmq-diagnostics -q ping
34+
interval: 30s
35+
timeout: 30s
36+
retries: 3
37+
start_period: 10s
38+
39+
volumes:
40+
rabbitmq_data:
41+

0 commit comments

Comments
 (0)