Skip to content
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
31 changes: 3 additions & 28 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 🚀 Deploy
name: 🚀 Check

on:
push:
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
node-version: 20

- name: 📥 Install deps
run: npm ci
run: npm ci && npx prisma generate

- name: 🔎 Type check
run: npm run typecheck --if-present
Expand All @@ -71,34 +71,9 @@ jobs:
node-version: 20

- name: 📥 Install deps
run: npm ci
run: npm ci && npx prisma generate

- name: 🔎 Build Project
run: npm run build


deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
needs: [lint, typecheck]
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 👀 Read app name
uses: SebRollen/toml-action@v1.0.2
id: app_name
with:
file: fly.toml
field: app

- name: 🎈 Setup Fly
uses: superfly/flyctl-actions/setup-flyctl@v1.4

- name: 🚀 Deploy Production
if: ${{ github.ref == 'refs/heads/master' }}
run: flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} --app ${{ steps.app_name.outputs.value }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ node_modules
/cypress/videos
/prisma/data.db
/prisma/data.db-journal
/data

.DS_Store

Expand Down
10 changes: 0 additions & 10 deletions .husky/pre-commit

This file was deleted.

2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore-scripts=true

77 changes: 26 additions & 51 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,37 @@
# base node image
FROM node:22-bullseye-slim as base

# set for base and all layer that inherit from it
ENV NODE_ENV production

# Install openssl for Prisma
RUN apt-get update && apt-get install -y openssl sqlite3

# Install all node_modules, including dev dependencies
FROM base as deps
FROM node:22-bullseye-slim AS base
RUN apt-get update && apt-get install -y openssl

FROM base AS deps
WORKDIR /myapp
COPY package.json package-lock.json ./
RUN npm install --include=dev --ignore-scripts

ADD package.json package-lock.json ./
RUN npm install --include=dev

# Setup production node_modules
FROM base as production-deps

FROM base AS production-deps
WORKDIR /myapp
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --ignore-scripts

COPY --from=deps /myapp/node_modules /myapp/node_modules
ADD package.json package-lock.json ./
RUN npm prune --omit=dev

# Build the app
FROM base as build

FROM base AS build
WORKDIR /myapp

COPY --from=deps /myapp/node_modules /myapp/node_modules

ADD prisma .
COPY --from=deps /myapp/node_modules ./node_modules
COPY prisma ./prisma
RUN npx prisma generate

ADD . .
COPY . .
RUN npm run build

# Finally, build the production image with minimal footprint
FROM base

ENV DATABASE_URL=file:/data/sqlite.db
ENV PORT="8080"
ENV NODE_ENV="production"

# add shortcut for connecting to database CLI
RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli

WORKDIR /myapp

COPY --from=production-deps /myapp/node_modules /myapp/node_modules
COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma

COPY --from=build /myapp/build /myapp/build
COPY --from=build /myapp/public /myapp/public
COPY --from=build /myapp/package.json /myapp/package.json
COPY --from=build /myapp/start.sh /myapp/start.sh
COPY --from=build /myapp/prisma /myapp/prisma
COPY --from=build /myapp/scripts /myapp/scripts

ENTRYPOINT [ "./start.sh" ]
COPY --from=production-deps --chown=node:node /myapp/node_modules ./node_modules
COPY --from=build --chown=node:node /myapp/node_modules/.prisma ./node_modules/.prisma
COPY --from=build --chown=node:node /myapp/build ./build
COPY --from=build --chown=node:node /myapp/public ./public
COPY --from=build --chown=node:node /myapp/package.json ./package.json
COPY --from=build --chown=node:node /myapp/start.sh ./start.sh
COPY --from=build --chown=node:node /myapp/prisma ./prisma
COPY --from=build --chown=node:node /myapp/scripts ./scripts
ENV PORT="3000"
ENV NODE_ENV=production
EXPOSE 3000
RUN mkdir -p /data && chown -R node:node /data
USER node
ENTRYPOINT ["./start.sh"]
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install dependencies
install:
npm install
npm install && npx prisma generate

# Run migrations and collect static files
bootstrap:
Expand Down
41 changes: 30 additions & 11 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
version: '3.8'

services:
dev:
image: neovim-dev # Use the pre-built image
container_name: johncom-dev
app:
build: .
container_name: johncom
restart: unless-stopped
expose:
- "3000"
env_file:
- .env
environment:
DATABASE_URL: file:/data/db.sqlite
NODE_ENV: production
PORT: 3000
volumes:
- .:/workspace # Mount current directory
- ~/.config/nvim:/home/node/.config/nvim:ro
- ~/.local/share/nvim:/home/node/.local/share/nvim
stdin_open: true
tty: true
command: tail -f /dev/null
- ./data:/data
networks:
- web
# dev:
# image: neovim-dev # Use the pre-built image
# container_name: johncom-dev
# volumes:
# - .:/workspace # Mount current directory
# - ~/.config/nvim:/home/node/.config/nvim:ro
# - ~/.local/share/nvim:/home/node/.local/share/nvim
# stdin_open: true
# tty: true
# command: tail -f /dev/null


networks:
web:
external: true
50 changes: 0 additions & 50 deletions fly.toml

This file was deleted.

Loading
Loading