-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1 Implement ability to configure spring-based docker containers
- Loading branch information
Igor Pavlenko
committed
May 5, 2024
1 parent
6f489bb
commit a025587
Showing
17 changed files
with
199 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
ggcode_modules/ | ||
|
||
# Expamples target directory | ||
examples/ | ||
/app/ | ||
|
||
# Lock file | ||
ggcode-info.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ actions: | |
- name: test/pgadmin | ||
path: actions/test/pgadmin.luau | ||
scrolls: | ||
- name: app | ||
path: scrolls/app | ||
- name: compose | ||
path: scrolls/compose | ||
- name: haproxy | ||
|
@@ -29,5 +31,5 @@ repositories: | |
- name: core | ||
uri: [email protected]:ntr1x/ggcode-repo-core.git | ||
targets: | ||
- name: '@examples' | ||
path: examples | ||
- name: '@app' | ||
path: app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local Service = require('compose/app/Service') | ||
|
||
return { | ||
Service = Service, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
local Meta = require('core/Meta') | ||
|
||
local Name = { | ||
__type = 'Name', | ||
name = nil, | ||
} | ||
|
||
function Name:new(o) | ||
o = o or {} | ||
setmetatable(o, self) | ||
self.__index = self | ||
return o | ||
end | ||
|
||
function Name:from(name: string) | ||
return Name:new({ | ||
name = name, | ||
}) | ||
end | ||
|
||
function Name:unwrap() | ||
return { | ||
name = self.name, | ||
} | ||
end | ||
|
||
return Name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
local Meta = require('core/Meta') | ||
|
||
local Service = { | ||
__type = 'Service', | ||
name = nil, | ||
image = nil, | ||
environment = nil, | ||
depends_on = nil, | ||
links = nil, | ||
} | ||
|
||
function Service:new(o) | ||
o = o or {} | ||
setmetatable(o, self) | ||
self.__index = self | ||
return o | ||
end | ||
|
||
function Service:from(name: string, image: string, environment: table) | ||
return Service:new({ | ||
name = name, | ||
image = image, | ||
depends_on = Meta:array {}, | ||
links = Meta:array {}, | ||
environment = environment or Meta:table {}, | ||
}) | ||
end | ||
|
||
function Service:with_env_variable(name: string, value: string) | ||
self.environment[name] = value | ||
return self | ||
end | ||
|
||
function Service:with_spring_datasource(datasource: table) | ||
self.environment.SPRING_DATASOURCE_URL = datasource.uri | ||
self.environment.SPRING_DATASOURCE_USERNAME = datasource.username | ||
self.environment.SPRING_DATASOURCE_PASSWORD = datasource.password | ||
return self | ||
end | ||
|
||
function Service:with_env_variables(environment: table) | ||
environment = environment or Meta:table {} | ||
|
||
for name, value in environment do | ||
self.environment[name] = value | ||
end | ||
|
||
return self | ||
end | ||
|
||
function Service:with_depends_on(name: string) | ||
self.depends_on[#self.depends_on + 1] = name | ||
return self | ||
end | ||
|
||
function Service:with_link(link: string) | ||
self.links[#self.links + 1] = link | ||
return self | ||
end | ||
|
||
function Service:unwrap_depends_on() | ||
if #self.depends_on > 0 then | ||
return self.depends_on | ||
end | ||
|
||
return nil | ||
end | ||
|
||
function Service:unwrap_links() | ||
if #self.links > 0 then | ||
return self.links | ||
end | ||
|
||
return nil | ||
end | ||
|
||
function Service:unwrap() | ||
return { | ||
service = { | ||
name = self.name, | ||
manifest = { | ||
image = self.image, | ||
environment = self.environment, | ||
depends_on = self:unwrap_depends_on(), | ||
links = self:unwrap_links() | ||
} | ||
} | ||
} | ||
end | ||
|
||
return Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- print(yaml:stringify({ | ||
-- bundle = bundle, | ||
-- service = service, | ||
-- volumes = volumes, | ||
-- })) |
8 changes: 8 additions & 0 deletions
8
scrolls/app/templates/compose/{bundle.name}/{service.name}.compose.yaml.luau
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
local config = { | ||
services = { | ||
[service.name] = service.manifest | ||
}, | ||
volumes = volumes, | ||
} | ||
|
||
template:println(yaml:stringify(config)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name: app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: app_service_api | ||
manifest: | ||
image: example/service_api:1.0-SNAPSHOT | ||
restart: unless-stopped | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 600M | ||
profiles: | ||
- app | ||
environment: | ||
JAVA_OPTS: "-Xmx512m -Xms256m" | ||
networks: | ||
default: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ manifest: | |
- env_kafka:/bitnami/kafka | ||
profiles: | ||
- env | ||
- app | ||
ports: | ||
- "9092:9092" | ||
- "29092:29092" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ manifest: | |
- env_postgres | ||
profiles: | ||
- env | ||
- admin | ||
environment: | ||
PGADMIN_DEFAULT_EMAIL: [email protected] | ||
PGADMIN_DEFAULT_PASSWORD: admin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters