Skip to content

Commit 82bbab6

Browse files
author
devnote-dev
committed
feat: remix initial commit
1 parent 6ff1d14 commit 82bbab6

Some content is hidden

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

55 files changed

+32973
-0
lines changed

.dockerignore

+7
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

+2
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

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/** @type {import('@types/eslint').Linter.BaseConfig} */
2+
module.exports = {
3+
extends: [
4+
"@remix-run/eslint-config",
5+
"@remix-run/eslint-config/node",
6+
"@remix-run/eslint-config/jest-testing-library",
7+
"prettier",
8+
],
9+
env: {
10+
"cypress/globals": true,
11+
},
12+
plugins: ["cypress"],
13+
// we're using vitest which has a very similar API to jest
14+
// (so the linting plugins work nicely), but it means we have to explicitly
15+
// set the jest version.
16+
settings: {
17+
jest: {
18+
version: 28,
19+
},
20+
},
21+
};

.github/workflows/deploy.yml

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

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
build/
2+
node_modules/
3+
public/build/
4+
cypress/screenshots/
5+
cypress/videos/
6+
7+
/prisma/data.db
8+
/prisma/data.db-journal
9+
10+
.env
11+
tailwind.css

.gitpod.Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM gitpod/workspace-full
2+
3+
# Install Fly
4+
RUN curl -L https://fly.io/install.sh | sh
5+
ENV FLYCTL_INSTALL="/home/gitpod/.fly"
6+
ENV PATH="$FLYCTL_INSTALL/bin:$PATH"
7+
8+
# Install GitHub CLI
9+
RUN brew install gh

.gitpod.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# https://www.gitpod.io/docs/config-gitpod-file
2+
3+
image:
4+
file: .gitpod.Dockerfile
5+
6+
ports:
7+
- port: 3000
8+
onOpen: notify
9+
10+
tasks:
11+
- name: Restore .env file
12+
command: |
13+
if [ -f .env ]; then
14+
# If this workspace already has a .env, don't override it
15+
# Local changes survive a workspace being opened and closed
16+
# but they will not persist between separate workspaces for the same repo
17+
18+
echo "Found .env in workspace"
19+
else
20+
# There is no .env
21+
if [ ! -n "${ENV}" ]; then
22+
# There is no $ENV from a previous workspace
23+
# Default to the example .env
24+
echo "Setting example .env"
25+
26+
cp .env.example .env
27+
else
28+
# After making changes to .env, run this line to persist it to $ENV
29+
# eval $(gp env -e ENV="$(base64 .env | tr -d '\n')")
30+
#
31+
# Environment variables set this way are shared between all your workspaces for this repo
32+
# The lines below will read $ENV and print a .env file
33+
34+
echo "Restoring .env from Gitpod"
35+
36+
echo "${ENV}" | base64 -d | tee .env > /dev/null
37+
fi
38+
fi
39+
40+
- init: npm install
41+
command: npm run setup && npm run dev
42+
43+
vscode:
44+
extensions:
45+
- ms-azuretools.vscode-docker
46+
- esbenp.prettier-vscode
47+
- dbaeumer.vscode-eslint
48+
- bradlc.vscode-tailwindcss

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
3+
/build
4+
/public/build
5+
.env
6+
7+
/app/styles/tailwind.css

Dockerfile

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 sqlite3
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 .npmrc ./
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 .npmrc ./
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 build
39+
40+
# Finally, build the production image with minimal footprint
41+
FROM base
42+
43+
ENV DATABASE_URL=file:/data/sqlite.db
44+
ENV PORT="8080"
45+
ENV NODE_ENV="production"
46+
47+
# add shortcut for connecting to database CLI
48+
RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli
49+
50+
WORKDIR /myapp
51+
52+
COPY --from=production-deps /myapp/node_modules /myapp/node_modules
53+
COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma
54+
55+
COPY --from=build /myapp/build /myapp/build
56+
COPY --from=build /myapp/public /myapp/public
57+
COPY --from=build /myapp/package.json /myapp/package.json
58+
COPY --from=build /myapp/start.sh /myapp/start.sh
59+
COPY --from=build /myapp/prisma /myapp/prisma
60+
61+
ENTRYPOINT [ "./start.sh" ]

0 commit comments

Comments
 (0)