-
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.
- Loading branch information
Showing
18 changed files
with
605 additions
and
5,246 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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# flyctl launch added from .gitignore | ||
# Dependency directories | ||
**/node_modules | ||
**/jspm_packages | ||
|
||
# Optional npm cache directory | ||
**/.npm | ||
|
||
# database | ||
**/*.db | ||
**/*.sqlite | ||
**/*.sqlite* | ||
|
||
# Optional eslint cache | ||
**/.eslintcache | ||
|
||
# Optional REPL history | ||
**/.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
**/*.tgz | ||
|
||
# Yarn Integrity file | ||
**/.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
**/.env | ||
**/.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
**/.cache | ||
**/.parcel-cache | ||
|
||
# Next.js build output | ||
**/.next | ||
**/out | ||
|
||
# Nuxt.js build / generate output | ||
**/.nuxt | ||
**/dist | ||
|
||
# Gatsby files | ||
**/.cache | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
**/.vuepress/dist | ||
|
||
# Serverless directories | ||
**/.serverless | ||
|
||
# FuseBox cache | ||
**/.fusebox | ||
|
||
# DynamoDB Local files | ||
**/.dynamodb | ||
|
||
# TernJS port file | ||
**/.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
**/.vscode-test | ||
|
||
# yarn v2 | ||
**/.yarn/cache | ||
**/.yarn/unplugged | ||
**/.yarn/build-state.yml | ||
**/.yarn/install-state.gz | ||
**/.pnp.* | ||
|
||
# Logs | ||
**/logs | ||
**/*.log | ||
**/npm-debug.log* | ||
**/yarn-debug.log* | ||
**/yarn-error.log* | ||
**/lerna-debug.log* | ||
|
||
# OS generated files | ||
**/.DS_Store | ||
**/.DS_Store? | ||
**/._* | ||
**/.Spotlight-V100 | ||
**/.Trashes | ||
**/ehthumbs.db | ||
**/Thumbs.db | ||
fly.toml |
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,18 @@ | ||
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ | ||
|
||
name: Fly Deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
name: Deploy app | ||
runs-on: ubuntu-latest | ||
concurrency: deploy-group # optional: ensure only one action runs at a time | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --remote-only | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
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 |
---|---|---|
@@ -1,26 +1,28 @@ | ||
FROM node:20-bullseye | ||
#!/bin/bash | ||
set -e | ||
|
||
RUN apt-get update && apt-get install -y sqlite3 | ||
# Set the migrations directory | ||
MIGRATIONS_DIR="./db/migrations" | ||
|
||
WORKDIR /app | ||
# Create the data directory if it doesn't exist | ||
mkdir -p /data | ||
|
||
COPY package.json ./ | ||
RUN npm install | ||
# rebuild sqlite3 for bullseye | ||
RUN npm rebuild sqlite3 | ||
if [ ! -f /data/mydb.sqlite ]; then | ||
echo "Database not found, creating and running migrations..." | ||
touch /data/mydb.sqlite | ||
chmod 644 /data/mydb.sqlite | ||
dbmate --migrations-dir "$MIGRATIONS_DIR" up | ||
echo "Database created and migrations applied." | ||
else | ||
echo "Database found, checking for unapplied migrations..." | ||
if dbmate --migrations-dir "$MIGRATIONS_DIR" status | grep -q "Pending"; then | ||
echo "Unapplied migrations found. Applying..." | ||
dbmate --migrations-dir "$MIGRATIONS_DIR" up | ||
echo "Migrations completed." | ||
else | ||
echo "No unapplied migrations found." | ||
fi | ||
fi | ||
|
||
COPY ./src ./src | ||
RUN mkdir -p ./db | ||
COPY ./db/migrations ./db/migrations | ||
COPY ./db/schema.sql ./db/ | ||
|
||
RUN mkdir -p /app/data && touch /app/data/mydb.sqlite | ||
RUN chmod -R 777 /app/data | ||
ENV DATABASE_URL=sqlite:./data/mydb.sqlite | ||
RUN npm run db:migrate | ||
# show tables | ||
RUN sqlite3 /app/data/mydb.sqlite "select 1;" | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm", "start"] | ||
# Execute the command passed to the script | ||
exec "$@" |
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,15 @@ | ||
-- migrate:up | ||
CREATE TABLE IF NOT EXISTS todo_items ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
list_id INTEGER NOT NULL, | ||
title TEXT NOT NULL, | ||
description TEXT, | ||
is_completed BOOLEAN DEFAULT 0, | ||
due_date DATE, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
-- migrate:down | ||
DROP TABLE IF EXISTS todo_items; | ||
|
||
|
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 @@ | ||
-- migrate:up | ||
ALTER TABLE todo_items ADD COLUMN user_id TEXT; | ||
CREATE INDEX idx_todo_items_user_id ON todo_items(user_id); | ||
|
||
|
||
-- migrate:down | ||
ALTER TABLE todo_items DROP COLUMN user_id; | ||
DROP INDEX idx_todo_items_user_id; |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# fly.toml app configuration file generated for demo-htmx-nodejs on 2024-09-12T16:06:43-07:00 | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = 'demo-htmx-nodejs' | ||
primary_region = 'sjc' | ||
|
||
[mounts] | ||
source="data" | ||
destination="/data" | ||
initial_size="1gb" | ||
|
||
[build] | ||
|
||
[http_service] | ||
internal_port = 3000 | ||
force_https = true | ||
auto_stop_machines = 'stop' | ||
auto_start_machines = true | ||
min_machines_running = 0 | ||
processes = ['app'] | ||
|
||
[[vm]] | ||
memory = '1gb' | ||
cpu_kind = 'shared' | ||
cpus = 1 |
Oops, something went wrong.