Skip to content

Commit

Permalink
install and run litestream from npm if Dockerfile exists
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Jan 11, 2025
1 parent b66d8c5 commit 60efe5d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 4 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 5 additions & 1 deletion gdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ export class GDF {
modules.push('@sveltejs/adapter-node')
}

if (this.litestream && !this.#pj.dependencies?.['@flydotio/litestream']) {
modules.push('@flydotio/litestream')
}

if (modules.length === 0) return
const add = this.packager === 'npm' ? 'install' : 'add'
for (const module of modules) {
Expand Down Expand Up @@ -978,7 +982,7 @@ export class GDF {
if (this.entrypoint) {
if (!this.#dockerfileExists || this.options.force) {
templates['docker-entrypoint.ejs'] = `${this.configDir}docker-entrypoint.js`
} else if (this.options.skip && fs.existsSync(path.join(appdir, 'fly.toml'))) {
} else if (this.setupScriptType === 'dbsetup') {
templates['docker-entrypoint.ejs'] = `${this.configDir}dbsetup.js`
}
}
Expand Down
55 changes: 53 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"node": ">=16.0.0"
},
"dependencies": {
"@flydotio/litestream": "^1.0.0",
"@sveltejs/adapter-node": "^5.2.11",
"chalk": "^5.3.0",
"diff": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion templates/docker-entrypoint.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ if (process.env.DATABASE_URL) {
<%= tab(n) %>// launch application
<% if (litestream) { -%>
<%= tab(n) %>if (process.env.BUCKET_NAME) {
<%= tab(n+1) %>await exec(`litestream replicate -config litestream.yml -exec ${JSON.stringify(process.argv.slice(2).join(' '))}`)
<%= tab(n+1) %>await exec(`<% if (setupScriptType == 'dbsetup') { %>npx <% } %>litestream replicate -config litestream.yml -exec ${JSON.stringify(process.argv.slice(2).join(' '))}`)
<%= tab(n) %>} else {
<%= tab(n+1) %>await exec(process.argv.slice(2).join(' '))
<%= tab(n) %>}
Expand Down

0 comments on commit 60efe5d

Please sign in to comment.