Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented github actions workflow for fly deploy #5

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Fly Deployment on Merge
on:
pull_request:
branches:
- main
types:
- closed
jobs:
deploy_when_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
concurrency: deploy-group
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
with:
version: 0.2.55
- run: bun fly:deploy
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
21 changes: 14 additions & 7 deletions Dockerfile.production
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ LABEL fly_launch_runtime="Bun"

RUN npm install -g bun

WORKDIR /app
# Set production environment
ENV NODE_ENV="production"

# FROM base AS build
WORKDIR /app

# 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 curl && \
# curl -fsSL https://bun.sh/install | bash
# Update package lists and install ca-certificates
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Install node modules
COPY --link bun.lockb package.json ./
Expand All @@ -24,4 +25,10 @@ RUN bun install --production
# Copy application code
COPY --link . .

CMD ["bun", "run", "start:prod"]
RUN bun tailwind:prod

RUN bunx mix

COPY --link . .

CMD ["bun", "run", "src/index.tsx"]
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# fly.toml app configuration file generated for hono-habit-tracker on 2024-04-30T02:40:49+02:00
# fly.toml app configuration file generated for habit-tracker-mongodb on 2024-07-11T05:14:01+02:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'hono-habit-tracker'
app = 'habit-tracker-mongodb'
primary_region = 'cdg'

[build]
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"docker:dev:up": "docker compose --env-file ./.env.development up --build mongo dev",
"docker:dev:down": "docker compose --env-file ./.env.development down mongo dev",
"docker:prod:up": "docker compose --env-file ./.env.production up --build app",
"docker:prod:down": "docker compose --env-file ./.env.production down app"
"docker:prod:down": "docker compose --env-file ./.env.production down app",
"fly:deploy": "flyctl deploy --dockerfile Dockerfile.production"
},
"dependencies": {
"@alpinejs/collapse": "^3.13.10",
Expand All @@ -38,6 +39,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@flydotio/dockerfile": "latest",
"@types/alpinejs": "^3.13.10",
"@types/bun": "latest",
"concurrently": "^8.2.2",
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export type AppVariables = {
const app = new Hono<{ Variables: AppVariables }>();
connectDB();

// process.on("SIGINT", handleDisconnectDBWhenExit);
// process.on("SIGTERM", handleDisconnectDBWhenExit);
process.on("SIGINT", handleDisconnectDBWhenExit);
process.on("SIGTERM", handleDisconnectDBWhenExit);

app
.use("/public/*", serveStatic({ root: "./" }))
Expand Down
Loading