Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit a915f7d

Browse files
committed
init
0 parents  commit a915f7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+24496
-0
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/node_modules
2+
*.log
3+
.DS_Store
4+
.env
5+
/.cache
6+
/public/build
7+
/build

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DATABASE_URL="file:./data.db?connection_limit=1"
2+
SESSION_SECRET="super-duper-s3cret"

.eslintrc.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const testingLibraryRules = {
2+
"testing-library/await-async-query": "error",
3+
"testing-library/await-async-utils": "error",
4+
"testing-library/no-await-sync-events": "error",
5+
"testing-library/no-await-sync-query": "error",
6+
"testing-library/no-debugging-utils": "warn",
7+
"testing-library/no-dom-import": ["error", "react"],
8+
"testing-library/no-promise-in-fire-event": "error",
9+
"testing-library/no-render-in-setup": "error",
10+
"testing-library/no-unnecessary-act": "error",
11+
"testing-library/no-wait-for-empty-callback": "error",
12+
"testing-library/no-wait-for-multiple-assertions": "error",
13+
"testing-library/no-wait-for-side-effects": "error",
14+
"testing-library/no-wait-for-snapshot": "error",
15+
"testing-library/prefer-find-by": "error",
16+
"testing-library/prefer-presence-queries": "error",
17+
"testing-library/prefer-query-by-disappearance": "error",
18+
"testing-library/prefer-screen-queries": "warn",
19+
"testing-library/prefer-user-event": "warn",
20+
"testing-library/prefer-wait-for": "error",
21+
"testing-library/render-result-naming-convention": "warn",
22+
};
23+
24+
/**
25+
* @type {import('@types/eslint').Linter.BaseConfig}
26+
*/
27+
module.exports = {
28+
extends: ["@remix-run/eslint-config", "prettier"],
29+
rules: {
30+
// having a type the same name as a variable is totally fine
31+
"@typescript-eslint/no-redeclare": "off",
32+
"@typescript-eslint/consistent-type-imports": "error",
33+
},
34+
overrides: [
35+
{
36+
files: ["**/*.test.{js,jsx,ts,tsx}"],
37+
env: {
38+
"jest/globals": true,
39+
},
40+
plugins: ["jest-dom", "jest", "testing-library"],
41+
settings: {
42+
jest: {
43+
version: 27,
44+
},
45+
},
46+
rules: {
47+
"jest/no-conditional-expect": "error",
48+
"jest/no-deprecated-functions": "error",
49+
"jest/no-disabled-tests": "warn",
50+
"jest/no-export": "error",
51+
"jest/no-focused-tests": "error",
52+
"jest/no-identical-title": "error",
53+
"jest/no-if": "error",
54+
"jest/no-interpolation-in-snapshots": "error",
55+
"jest/no-large-snapshots": ["warn", { maxSize: 300 }],
56+
"jest/no-mocks-import": "error",
57+
"jest/valid-describe-callback": "error",
58+
"jest/valid-expect": "error",
59+
"jest/valid-expect-in-promise": "error",
60+
"jest/valid-title": "warn",
61+
62+
"jest-dom/prefer-checked": "error",
63+
"jest-dom/prefer-empty": "error",
64+
"jest-dom/prefer-enabled-disabled": "error",
65+
"jest-dom/prefer-focus": "error",
66+
"jest-dom/prefer-in-document": "error",
67+
"jest-dom/prefer-required": "error",
68+
"jest-dom/prefer-to-have-attribute": "error",
69+
"jest-dom/prefer-to-have-class": "error",
70+
"jest-dom/prefer-to-have-style": "error",
71+
"jest-dom/prefer-to-have-text-content": "error",
72+
"jest-dom/prefer-to-have-value": "error",
73+
74+
...testingLibraryRules,
75+
},
76+
},
77+
{
78+
files: ["cypress/**/*.{js,jsx,ts,tsx}"],
79+
rules: {
80+
...testingLibraryRules,
81+
// override these because they don't make sense in cypress:
82+
"testing-library/prefer-screen-queries": "off",
83+
"testing-library/await-async-query": "off",
84+
},
85+
},
86+
],
87+
};

.github/workflows/deploy.yml

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
name: 🚀 Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- dev
7+
pull_request: {}
8+
9+
jobs:
10+
lint:
11+
name: ⬣ ESLint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: 🛑 Cancel Previous Runs
15+
uses: styfle/[email protected]
16+
17+
- name: ⬇️ Checkout repo
18+
uses: actions/checkout@v2
19+
20+
- name: ⎔ Setup node
21+
uses: actions/setup-node@v2
22+
with:
23+
node-version: 16
24+
25+
- name: 📥 Download deps
26+
uses: bahmutov/npm-install@v1
27+
28+
- name: 🔬 Lint
29+
run: npm run lint
30+
31+
typecheck:
32+
name: ʦ TypeScript
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: 🛑 Cancel Previous Runs
36+
uses: styfle/[email protected]
37+
38+
- name: ⬇️ Checkout repo
39+
uses: actions/checkout@v2
40+
41+
- name: ⎔ Setup node
42+
uses: actions/setup-node@v2
43+
with:
44+
node-version: 16
45+
46+
- name: 📥 Download deps
47+
uses: bahmutov/npm-install@v1
48+
49+
- name: 🔎 Type check
50+
run: npm run typecheck
51+
52+
vitest:
53+
name: ⚡ Vitest
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: 🛑 Cancel Previous Runs
57+
uses: styfle/[email protected]
58+
59+
- name: ⬇️ Checkout repo
60+
uses: actions/checkout@v2
61+
62+
- name: ⎔ Setup node
63+
uses: actions/setup-node@v2
64+
with:
65+
node-version: 16
66+
67+
- name: 📥 Download deps
68+
uses: bahmutov/npm-install@v1
69+
70+
- name: ⚡ Run vitest
71+
run: npm run test -- --coverage
72+
73+
cypress:
74+
name: ⚫️ Cypress
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: 🛑 Cancel Previous Runs
78+
uses: styfle/[email protected]
79+
80+
- name: ⬇️ Checkout repo
81+
uses: actions/checkout@v2
82+
83+
- name: 🏄 Copy test env vars
84+
run: cp .env.example .env
85+
86+
- name: ⎔ Setup node
87+
uses: actions/setup-node@v2
88+
with:
89+
node-version: 16
90+
91+
- name: 📥 Download deps
92+
uses: bahmutov/npm-install@v1
93+
94+
- name: ⚙️ Build
95+
run: npm run build
96+
97+
- name: 🐳 Docker compose
98+
run: docker-compose up -d && sleep 3 && npx prisma migrate reset --force
99+
env:
100+
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/postgres"
101+
102+
- name: 🌳 Cypress run
103+
uses: cypress-io/github-action@v2
104+
with:
105+
start: npm run start:mocks
106+
wait-on: "http://localhost:8811"
107+
env:
108+
PORT: "8811"
109+
110+
build:
111+
name: 🐳 Build
112+
# only build/deploy main branch on pushes
113+
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: 🛑 Cancel Previous Runs
117+
uses: styfle/[email protected]
118+
119+
- name: ⬇️ Checkout repo
120+
uses: actions/checkout@v2
121+
122+
- name: 👀 Read app name
123+
uses: SebRollen/[email protected]
124+
id: app_name
125+
with:
126+
file: "fly.toml"
127+
field: "app"
128+
129+
- name: 🐳 Set up Docker Buildx
130+
uses: docker/setup-buildx-action@v1
131+
132+
# Setup cache
133+
- name: ⚡️ Cache Docker layers
134+
uses: actions/cache@v2
135+
with:
136+
path: /tmp/.buildx-cache
137+
key: ${{ runner.os }}-buildx-${{ github.sha }}
138+
restore-keys: |
139+
${{ runner.os }}-buildx-
140+
141+
- name: 🔑 Fly Registry Auth
142+
uses: docker/login-action@v1
143+
with:
144+
registry: registry.fly.io
145+
username: x
146+
password: ${{ secrets.FLY_API_TOKEN }}
147+
148+
- name: 🐳 Docker build
149+
uses: docker/build-push-action@v2
150+
with:
151+
context: .
152+
push: true
153+
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
154+
build-args: |
155+
COMMIT_SHA=${{ github.sha }}
156+
cache-from: type=local,src=/tmp/.buildx-cache
157+
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
158+
159+
# This ugly bit is necessary if you don't want your cache to grow forever
160+
# till it hits GitHub's limit of 5GB.
161+
# Temp fix
162+
# https://github.com/docker/build-push-action/issues/252
163+
# https://github.com/moby/buildkit/issues/1896
164+
- name: 🚚 Move cache
165+
run: |
166+
rm -rf /tmp/.buildx-cache
167+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
168+
169+
deploy:
170+
name: 🚀 Deploy
171+
runs-on: ubuntu-latest
172+
needs: [lint, typecheck, vitest, cypress, build]
173+
# only build/deploy main branch on pushes
174+
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
175+
176+
steps:
177+
- name: 🛑 Cancel Previous Runs
178+
uses: styfle/[email protected]
179+
180+
- name: ⬇️ Checkout repo
181+
uses: actions/checkout@v2
182+
183+
- name: 👀 Read app name
184+
uses: SebRollen/[email protected]
185+
id: app_name
186+
with:
187+
file: "fly.toml"
188+
field: "app"
189+
190+
- name: 🚀 Deploy Staging
191+
if: ${{ github.ref == 'refs/heads/dev' }}
192+
uses: superfly/[email protected]
193+
with:
194+
args: "deploy --app ${{ steps.app_name.outputs.value }}-staging --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
195+
env:
196+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
197+
198+
- name: 🚀 Deploy Production
199+
if: ${{ github.ref == 'refs/heads/main' }}
200+
uses: superfly/[email protected]
201+
with:
202+
args: "deploy --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
203+
env:
204+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
/build
3+
/public/build
4+
/prisma/data.db
5+
/prisma/data.db-journal
6+
.env
7+
/cypress/screenshots
8+
/cypress/videos

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules
2+
/.cache
3+
/build
4+
/public/build
5+
/postgres-data
6+
.env

Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# base node image
2+
FROM node:16-bullseye-slim as base
3+
4+
# set for base and all layer that inherit from it
5+
ENV NODE_ENV production
6+
7+
# Install openssl for Prisma
8+
RUN apt-get update && apt-get install -y openssl
9+
10+
# Install all node_modules, including dev dependencies
11+
FROM base as deps
12+
13+
WORKDIR /myapp
14+
15+
ADD package.json package-lock.json ./
16+
RUN npm install --production=false
17+
18+
# Setup production node_modules
19+
FROM base as production-deps
20+
21+
WORKDIR /myapp
22+
23+
COPY --from=deps /myapp/node_modules /myapp/node_modules
24+
ADD package.json package-lock.json ./
25+
RUN npm prune --production
26+
27+
# Build the app
28+
FROM base as build
29+
30+
WORKDIR /myapp
31+
32+
COPY --from=deps /myapp/node_modules /myapp/node_modules
33+
34+
ADD prisma .
35+
RUN npx prisma generate
36+
37+
ADD . .
38+
RUN npm run postinstall
39+
RUN npm run build
40+
41+
# Finally, build the production image with minimal footprint
42+
FROM base
43+
44+
WORKDIR /myapp
45+
46+
COPY --from=production-deps /myapp/node_modules /myapp/node_modules
47+
COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma
48+
49+
COPY --from=build /myapp/build /myapp/build
50+
COPY --from=build /myapp/public /myapp/public
51+
ADD . .
52+
53+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)