-
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
Adriana Cardoso
committed
Nov 4, 2024
1 parent
4db503d
commit 513db11
Showing
9 changed files
with
258 additions
and
24 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,19 @@ | ||
# Dependencies and AdonisJS build | ||
node_modules | ||
build | ||
tmp | ||
|
||
# Secrets | ||
*.env* | ||
!.env.example | ||
|
||
# Build tools specific | ||
*.log | ||
|
||
# Editors specific | ||
.fleet | ||
.idea | ||
.vscode | ||
|
||
# Platform specific | ||
.DS_Store |
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
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,49 @@ | ||
# syntax = docker/dockerfile:1 | ||
ARG NODE_VERSION=21.6.1 | ||
FROM node:${NODE_VERSION}-slim AS base | ||
|
||
LABEL fly_launch_runtime="AdonisJS" | ||
|
||
# AdonisJS app lives here | ||
WORKDIR /app | ||
|
||
# Set production environment | ||
ENV NODE_ENV="production" | ||
ARG YARN_VERSION=1.22.19 | ||
RUN npm install -g yarn@$YARN_VERSION --force | ||
|
||
# Throw-away build stage to reduce size of final image | ||
FROM base AS build | ||
|
||
# Install packages needed to build node modules | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 | ||
|
||
# Install node modules | ||
COPY package.json yarn.lock ./ | ||
RUN yarn install --frozen-lockfile --production=false | ||
|
||
# Copy application code | ||
COPY . . | ||
|
||
# Build application | ||
RUN yarn run build | ||
|
||
# Final stage for app image | ||
FROM base | ||
|
||
# Copy built application | ||
COPY --from=build /app /app | ||
|
||
# Entrypoint sets up the container. | ||
ENTRYPOINT [ "/app/docker-entrypoint.js" ] | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 3000 | ||
ENV CACHE_VIEWS="true" \ | ||
DB_CONNECTION="pg" \ | ||
DRIVE_DISK="local" \ | ||
HOST="0.0.0.0" \ | ||
PORT="3000" \ | ||
SESSION_DRIVER="cookie" | ||
CMD [ "node", "build/bin/server.js" ] |
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,36 @@ | ||
#!/usr/bin/env node | ||
|
||
import { spawn } from 'node:child_process' | ||
|
||
const env = { ...process.env } | ||
|
||
if (process.env.DATABASE_URL) { | ||
try { | ||
const databaseUrl = new URL(process.env.DATABASE_URL) | ||
env.PG_HOST = databaseUrl.hostname | ||
env.PG_PORT = databaseUrl.port | ||
env.PG_USER = databaseUrl.username | ||
env.PG_PASSWORD = databaseUrl.password | ||
env.PG_DB_NAME = databaseUrl.pathname.slice(1) | ||
} catch (err) { | ||
console.error('Invalid DATABASE_URL') | ||
} | ||
} | ||
|
||
;(async() => { | ||
// launch application | ||
await exec(process.argv.slice(2).join(' ')) | ||
})() | ||
|
||
function exec(command) { | ||
const child = spawn(command, { shell: true, stdio: 'inherit', env }) | ||
return new Promise((resolve, reject) => { | ||
child.on('exit', code => { | ||
if (code === 0) { | ||
resolve() | ||
} else { | ||
reject(new Error(`${command} failed rc=${code}`)) | ||
} | ||
}) | ||
}) | ||
} |
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,22 @@ | ||
# fly.toml app configuration file generated for social-adonis on 2024-11-04T11:14:11Z | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = 'social-adonis' | ||
primary_region = 'cdg' | ||
|
||
[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 |
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
Oops, something went wrong.