Skip to content

Commit

Permalink
v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev XO committed Jul 15, 2023
0 parents commit 8ad438e
Show file tree
Hide file tree
Showing 104 changed files with 4,886 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/node_modules
*.log
.DS_Store
.env
/.cache
/public/build
/build
27 changes: 27 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Base.
NODE_ENV="development"
SESSION_SECRET="SESSION_SECRET"
ENCRYPTION_SECRET="ENCRYPTION_SECRET"

# Host.
DEV_HOST_URL="http://localhost:3000"
PROD_HOST_URL="https://example.com"

# Environment variables declared in this file are automatically made available to Prisma.
# More details: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
DATABASE_URL="file:./data.db?connection_limit=1"

# [Optional] Social Authentification.
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""

# [Optional] Email Provider.
EMAIL_PROVIDER_API_KEY=""

# Stripe.
STRIPE_PUBLIC_KEY="STRIPE_PUBLIC_KEY"
STRIPE_SECRET_KEY="STRIPE_SECRET_KEY"

# Stripe Webhook.
DEV_STRIPE_WEBHOOK_ENDPOINT=""
PROD_STRIPE_WEBHOOK_ENDPOINT=""
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
extends: ['@remix-run/eslint-config', '@remix-run/eslint-config/node', 'prettier'],
ignorePatterns: ['build'],
}
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Learn about Dependabot:
# https://docs.github.com/en/code-security/dependabot

version: 2
updates:
# Enable version updates for npm.
- package-ecosystem: 'npm'
# Look for `package.json` and `lock` files in the `root` directory.
directory: '/'
# Check the npm registry for updates every day.
schedule:
interval: 'daily'

# Enable version updates for Github-Actions.
- package-ecosystem: github-actions
# Look in the `root` directory.
directory: /
# Check for updates every day (weekdays)
schedule:
interval: daily
186 changes: 186 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: 🚀 Deploy
on:
push:
branches:
- main
- dev
pull_request: {}

permissions:
actions: write
contents: read

jobs:
lint:
name: ⬣ ESLint
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]

- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Dependencies
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: Run Lint
run: npm run lint

typecheck:
name: ʦ TypeScript
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]

- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Dependencies
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: Run Typechecking
run: npm run typecheck --if-present

playwright:
name: 🎭 Playwright
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]

- name: Checkout Repository
uses: actions/checkout@v3

- name: Copy Environment Variables
run: cp .env.example .env

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Dependencies
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Setup Database
run: npx prisma migrate reset --force --skip-seed

- name: Build
run: npm run build

- name: Run Playwright Tests
run: npx playwright test

- name: Upload Report
uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

build:
name: 🐳 Build
# Only build / deploy main branch on pushes.
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]

- name: Checkout Repository
uses: actions/checkout@v3

- name: Read App Name
uses: SebRollen/[email protected]
id: app_name
with:
file: 'fly.toml'
field: 'app'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.9.1

- name: Cache Docker Layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Fly Registry Auth
uses: docker/login-action@v2
with:
registry: registry.fly.io
username: x
password: ${{ secrets.FLY_API_TOKEN }}

- name: Docker build
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
build-args: |
COMMIT_SHA=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: Move Cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
needs: [lint, typecheck, playwright, build]
# Only build / deploy main branch on pushes.
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]

- name: Checkout Repository
uses: actions/checkout@v3

- name: Read App Name
uses: SebRollen/[email protected]
id: app_name
with:
file: 'fly.toml'
field: 'app'

- name: Deploy Production
if: ${{ github.ref == 'refs/heads/main' }}
uses: superfly/[email protected]
with:
args: 'deploy --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}'
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Package Managers.
package-lock.json
yarn.lock
pnpm-lock.yaml
pnpm-lock.yml
node_modules

# Editor Configs.
.idea
.vscode
.DS_Store

# Miscelaneous.
/.cache
/build
/public/build
.env

# Tests.
/coverage

# Prisma.
/prisma/data.db
/prisma/data.db-journal
/prisma/migrations

# Docker PostgreSQL.
postgres-data
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
auto-install-peers=true
strict-peer-dependencies=false
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules

/build
/public/build
.env

/app/styles/tailwind.css
14 changes: 14 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"tabWidth": 2,
"printWidth": 90,
"semi": false,
"useTabs": false,
"bracketSpacing": true,
"bracketSameLine": true,
"singleQuote": true,
"jsxSingleQuote": false,
"singleAttributePerLine": false,
"arrowParens": "always",
"trailingComma": "all",
"plugins": ["prettier-plugin-tailwindcss"]
}
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Base node image.
FROM node:16-bullseye-slim as base

# Set global environment variables.
ENV PORT="8080"
ENV NODE_ENV="production"
ENV DATABASE_URL=file:/data/sqlite.db

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

# Install all node_modules, including dev dependencies.
FROM base as deps

WORKDIR /myapp

ADD package.json ./
RUN npm install --production=false

# Setup production node_modules.
FROM base as production-deps

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

ADD package.json ./
RUN npm prune --production

# Build the app.
FROM base as build

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

ADD prisma .
RUN npx prisma generate

ADD . .
RUN npm run build

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

# 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/prisma /myapp/prisma
COPY --from=build /myapp/package.json /myapp/package.json
COPY --from=build /myapp/start.sh /myapp/start.sh

ENTRYPOINT [ "./start.sh" ]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Daniel Kanem

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 8ad438e

Please sign in to comment.