deploy that shit

This commit is contained in:
m5r 2022-06-27 02:26:06 +02:00
parent f034373406
commit d001fba764
8 changed files with 131 additions and 106 deletions

View File

@ -9,4 +9,4 @@ node_modules
/.cache
/public/build
/build
server.js
/server/index.js

View File

@ -15,53 +15,9 @@ jobs:
- run: npm ci
- run: npm run lint
e2e:
name: E2E tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13-alpine
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_USER: pgremixtape
POSTGRES_PASSWORD: pgpassword
POSTGRES_DB: remixtape
ports:
- "5432:5432"
redis:
image: redis:6-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- "6379:6379"
env:
DATABASE_URL: postgresql://pgremixtape:pgpassword@localhost:5432/remixtape
REDIS_URL: redis://localhost:6379
CI: true
steps:
- uses: actions/checkout@v2
- run: cp .env.example .env
- uses: actions/setup-node@v2
with:
node-version: 16
cache: "npm"
- run: npm ci
- run: npm run db:setup
- run: npm run build
- run: npx dotenv npm run e2e:ci
typecheck:
name: Typecheck
runs-on: ubuntu-latest
env:
HUSKY_SKIP_INSTALL: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
@ -70,10 +26,29 @@ jobs:
- run: npm ci
- run: npx tsc
deploy:
deploy_development:
if: github.ref == 'refs/heads/master'
needs: [lint, e2e, typecheck]
name: Deploy to Fly.io
needs: [lint, typecheck]
name: Deploy development environment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: superfly/flyctl-actions@master
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
with:
args: "deploy --strategy rolling -c ./fly.dev.toml"
- uses: appleboy/discord-action@master
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
args: "https://dev.shellphone.app deployed with commit `${{ github.event.head_commit.message }}` (`${{ github.sha }}`) from branch `${{ github.ref }}`"
deploy_production:
if: github.ref == 'refs/heads/production'
needs: [lint, typecheck]
name: Deploy production environment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -82,3 +57,8 @@ jobs:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
with:
args: "deploy --strategy rolling"
- uses: appleboy/discord-action@master
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
args: "https://www.shellphone.app deployed with commit `${{ github.event.head_commit.message }}` (`${{ github.sha }}`) from branch `${{ github.ref }}`"

View File

@ -51,7 +51,7 @@ COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma
COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public
COPY --from=build /app/server.js /app/server.js
COPY --from=build /app/server/index.js /app/server/index.js
ADD . .
CMD ["npm", "run", "start"]

View File

@ -20,10 +20,6 @@ invariant(
`Please define the "AWS_SES_FROM_EMAIL" environment variable`,
);
invariant(typeof process.env.REDIS_URL === "string", `Please define the "REDIS_URL" environment variable`);
invariant(
typeof process.env.TWILIO_AUTH_TOKEN === "string",
`Please define the "TWILIO_AUTH_TOKEN" environment variable`,
);
invariant(
typeof process.env.MASTER_ENCRYPTION_KEY === "string",
`Please define the "MASTER_ENCRYPTION_KEY" environment variable`,
@ -65,9 +61,6 @@ export default {
sentry: {
dsn: process.env.SENTRY_DSN,
},
twilio: {
authToken: process.env.TWILIO_AUTH_TOKEN,
},
webPush: {
privateKey: process.env.WEB_PUSH_VAPID_PRIVATE_KEY,
publicKey: process.env.WEB_PUSH_VAPID_PUBLIC_KEY,

View File

@ -23,11 +23,11 @@ export const voiceUrl = `${serverConfig.app.baseUrl}/webhook/call`;
export function getTwiMLName() {
switch (serverConfig.app.baseUrl) {
case "local.shellphone.app":
case "https://local.shellphone.app":
return "Shellphone LOCAL";
case "dev.shellphone.app":
case "https://dev.shellphone.app":
return "Shellphone DEV";
case "www.shellphone.app":
case "https://www.shellphone.app":
return "Shellphone";
}
}

53
fly.dev.toml Normal file
View File

@ -0,0 +1,53 @@
app = "shellphone-dev"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[deploy]
release_command = "npx prisma migrate deploy"
[env]
APP_BASE_URL = "https://dev.shellphone.app"
AWS_SES_FROM_EMAIL = "\"Mokhtar from Shellphone\" <mokhtar@shellphone.app>"
AWS_SES_REGION = "eu-central-1"
NODE_ENV = "production"
PORT = "8080"
[experimental]
allowed_public_ports = []
auto_rollback = true
[[services]]
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.http_checks]]
grace_period = "5s"
interval = 10000
method = "get"
path = "/healthcheck"
protocol = "http"
timeout = 2000
tls_skip_verify = false
[services.http_checks.headers]
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

View File

@ -1,18 +1,18 @@
app = "shellphoneappremixed-redis"
app = "shellphone-redis"
kill_signal = "SIGINT"
kill_timeout = 5
processes = [ ]
processes = []
[build]
image = "flyio/redis:6.2.6"
[experimental]
allowed_public_ports = [ ]
allowed_public_ports = []
auto_rollback = true
[[mounts]]
destination = "/data"
source = "shellphoneappremixed_redis_data"
source = "shellphone_redis_data"
[metrics]
port = 9_091

View File

@ -1,54 +1,53 @@
app = "shellphoneappremixed"
app = "shellphone-prod"
kill_signal = "SIGINT"
kill_timeout = 5
processes = [ ]
[env]
APP_BASE_URL = "https://shellphoneappremixed.fly.dev"
AWS_SES_FROM_EMAIL = "remixtape@fake.app"
AWS_SES_REGION = "eu-central-1"
NODE_ENV = "production"
PORT = "8080"
processes = []
[deploy]
release_command = "npx prisma migrate deploy"
release_command = "npx prisma migrate deploy"
[env]
APP_BASE_URL = "https://www.shellphone.app"
AWS_SES_FROM_EMAIL = "\"Mokhtar from Shellphone\" <mokhtar@shellphone.app>"
AWS_SES_REGION = "eu-central-1"
NODE_ENV = "production"
PORT = "8080"
[experimental]
allowed_public_ports = [ ]
auto_rollback = true
allowed_public_ports = []
auto_rollback = true
[[services]]
internal_port = 8_080
processes = [ "app" ]
protocol = "tcp"
script_checks = [ ]
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
handlers = [ "http" ]
port = 80
force_https = true
[[services.ports]]
handlers = [ "tls", "http" ]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.http_checks]]
interval = 10_000
grace_period = "5s"
method = "get"
path = "/healthcheck"
protocol = "http"
timeout = 2_000
tls_skip_verify = false
headers = { }
grace_period = "5s"
interval = 10000
method = "get"
path = "/healthcheck"
protocol = "http"
timeout = 2000
tls_skip_verify = false
[services.http_checks.headers]
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"