Skip to content

Commit 8c16f87

Browse files
authored
Merge pull request #7 from webNeat/develop
Set env vars at build time
2 parents e1dc04f + 8354985 commit 8c16f87

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
node_modules
44
dist
55
.tests
6-
archive
6+
archive
7+
.aider*
8+
.env

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hosty",
3-
"version": "0.0.1-alpha.15",
3+
"version": "0.0.1-alpha.16",
44
"description": "A code based opinionated way to self-host and manage web apps.",
55
"type": "module",
66
"main": "dist/index.js",

src/blocks/build_repo.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type Config = {
1414
source_changed: string
1515
}
1616
path?: string
17+
env?: Record<string, string>
1718
}
1819

1920
export function build_repo(config: Config): Block {
@@ -32,6 +33,16 @@ export function build_repo(config: Config): Block {
3233
{ repo: config.repo_url, version: config.branch, accept_hostkey: true, dest: '{{clone_dir.path}}' },
3334
{ when: 'source_file.changed' },
3435
),
36+
builtin.copy(
37+
`Create .env file`,
38+
{
39+
content: Object.entries(config.env || {})
40+
.map(([key, value]) => `${key}=${value}`)
41+
.join('\n'),
42+
dest: path.join(build_path, '.env'),
43+
},
44+
{ when: 'source_file.changed' },
45+
),
3546
builtin.stat(`Check if Dockerfile exists`, { path: path.join(build_path, 'Dockerfile') }, { register: 'dockerfile', when: 'source_file.changed' }),
3647
builtin.command(
3748
`Build the app using Dockerfile`,

src/services/app/git.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function get_deploy_tasks(server: Server, config: GitAppConfig): Tasks {
3030
image_name: config.name,
3131
facts: { source_changed: 'source_changed' },
3232
path: config.path,
33+
env: config.env,
3334
}),
3435
)
3536

tests/app-laravel-mysql-custom-docker.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ test('app: laravel + mysql + custom dockerfile', async ({ deploy, destroy, asser
1010
path: 'examples/php-laravel-mysql',
1111
domain: 'laravel.local',
1212
env: {
13-
APP_NAME: 'Laravel App',
13+
APP_NAME: '"Laravel App"',
1414
APP_ENV: 'production',
15-
APP_KEY: 'base64:MwtP4zRRiQnznkVkAPbKwwB9768wKSwHp4hYF7P5B8k=',
15+
APP_KEY: '"base64:MwtP4zRRiQnznkVkAPbKwwB9768wKSwHp4hYF7P5B8k="',
1616
APP_DEBUG: 'true',
1717
APP_TIMEZONE: 'UTC',
1818
APP_PORT: '80',

0 commit comments

Comments
 (0)