-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from lumastic/development
First prod release
- Loading branch information
Showing
103 changed files
with
14,125 additions
and
17,561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/node_modules | ||
*.log | ||
.DS_Store | ||
.env | ||
/.cache | ||
/public/build | ||
/build | ||
/prisma/data.db | ||
/prisma/data.db-journal | ||
Dockerfile | ||
scripts | ||
generators | ||
cypress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
public | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
name: 🚀 Deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- development | ||
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 repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: ⎔ Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: 📥 Download deps | ||
uses: bahmutov/npm-install@v1 | ||
with: | ||
useLockFile: false | ||
|
||
- name: 🔬 Lint | ||
run: npm run lint | ||
|
||
typecheck: | ||
name: ʦ TypeScript | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🛑 Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
|
||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: ⎔ Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: 📥 Download deps | ||
uses: bahmutov/npm-install@v1 | ||
with: | ||
useLockFile: false | ||
|
||
- name: 🔎 Type check | ||
run: npm run typecheck --if-present | ||
|
||
vitest: | ||
name: ⚡ Vitest | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🛑 Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
|
||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: ⎔ Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: 📥 Download deps | ||
uses: bahmutov/npm-install@v1 | ||
with: | ||
useLockFile: false | ||
|
||
- name: ⚡ Run vitest | ||
run: npm run test:unit:ci -- --coverage | ||
|
||
build: | ||
name: 🐳 Build | ||
# only build/deploy main branch on pushes | ||
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development') && github.event_name == 'push' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🛑 Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
|
||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: 👀 Read app name | ||
uses: SebRollen/[email protected] | ||
id: songbook-creator | ||
with: | ||
file: "fly.toml" | ||
field: "app" | ||
|
||
- name: 🐳 Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
version: v0.9.1 | ||
|
||
# Setup cache | ||
- 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@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: registry.fly.io/${{ steps.songbook-creator.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 | ||
|
||
# This ugly bit is necessary if you don't want your cache to grow forever | ||
# till it hits GitHub's limit of 5GB. | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
- 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, vitest, build] | ||
# only build/deploy main branch on pushes | ||
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development') && github.event_name == 'push' }} | ||
|
||
steps: | ||
- name: 🛑 Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
|
||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: 👀 Read app name | ||
uses: SebRollen/[email protected] | ||
id: songbook-creator | ||
with: | ||
file: "fly.toml" | ||
field: "app" | ||
|
||
- name: 🚀 Deploy Staging | ||
if: ${{ github.ref == 'refs/heads/development' }} | ||
uses: superfly/[email protected] | ||
with: | ||
args: "deploy --app ${{ steps.songbook-creator.outputs.value }}-staging --image registry.fly.io/${{ steps.songbook-creator.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}" | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
|
||
- name: 🚀 Deploy Production | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
uses: superfly/[email protected] | ||
with: | ||
args: "deploy --image registry.fly.io/${{ steps.songbook-creator.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}" | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,6 @@ node_modules | |
/prisma/data.db-journal | ||
/postgres-data | ||
|
||
.DS_Store | ||
.DS_Store | ||
coverage | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
legacy-peer-deps=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.cache | ||
.netlify | ||
public | ||
public | ||
*.hbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"tailwindCSS.classAttributes": ["class", "className", ".*Styles"] | ||
"tailwindCSS.classAttributes": ["class", "className", ".*Styles"], | ||
"yaml.schemas": { | ||
"https://json.schemastore.org/github-workflow.json": "file:///Users/drew/Sites/songbook-creator/.github/workflows/deploy.yml" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# base node image | ||
FROM node:18-bullseye-slim as base | ||
|
||
# Install openssl and sqlite3 for Prisma | ||
RUN apt-get update && apt-get install -y openssl sqlite3 | ||
|
||
# Install all node_modules, including dev dependencies | ||
FROM base as deps | ||
|
||
RUN mkdir /app/ | ||
WORKDIR /app/ | ||
|
||
ADD package.json .npmrc package-lock.json ./ | ||
RUN npm install | ||
|
||
# Setup production node_modules | ||
FROM base as production-deps | ||
|
||
RUN mkdir /app/ | ||
WORKDIR /app/ | ||
|
||
COPY --from=deps /app/node_modules /app/node_modules | ||
ADD package.json .npmrc package-lock.json /app/ | ||
RUN npm prune --omit=dev | ||
|
||
# Build the app | ||
FROM base as build | ||
|
||
RUN mkdir /app/ | ||
WORKDIR /app/ | ||
|
||
COPY --from=deps /app/node_modules /app/node_modules | ||
|
||
ADD prisma /app/prisma | ||
RUN npx prisma generate | ||
|
||
ADD . . | ||
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 | ||
|
||
RUN mkdir /app/ | ||
WORKDIR /app/ | ||
|
||
COPY --from=production-deps /app/node_modules /app/node_modules | ||
|
||
COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma | ||
|
||
COPY --from=build /app/build /app/build | ||
COPY --from=build /app/public /app/public | ||
COPY --from=build /app/package.json /app/package.json | ||
COPY --from=build /app/start.sh /app/start.sh | ||
COPY --from=build /app/prisma /app/prisma | ||
|
||
ADD . . | ||
|
||
RUN chmod +x start.sh | ||
EXPOSE 8080 | ||
CMD [ "./start.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { Dialog } from "./Dialog"; | ||
|
||
export const Basic = () => <Dialog />; | ||
export const Basic = () => <Dialog title="Test Dialog" />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.