Skip to content

Commit

Permalink
Docker (#1071)
Browse files Browse the repository at this point in the history
* Add type-check

* Switch to NPM

* Add Prisma Migrate and Dockerfile
  • Loading branch information
stephenwade authored Jul 3, 2023
1 parent 6d579a7 commit 5ec890a
Show file tree
Hide file tree
Showing 16 changed files with 15,378 additions and 9,062 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NODE_ENV=development
DATABASE_URL=mysql://festival:uyuUWZuc16TczBH6wrVRqpMUiDVBE7@localhost:3306/festival
AZURE_STORAGE_ACCOUNT=sndfli
AZURE_STORAGE_KEY=lAvDgmqK14DK8HaBYOvFxIRaHVO0TQm4imw3orVTUBkKYYSv/65IHgXzFvQX0xEK7InxVTAxEMEGpNepHwBkTA==
AZURE_STORAGE_WEBSITE_DOMAIN=sndfli.z13.web.core.windows.net
10 changes: 3 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: latest

- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
cache: npm

- run: pnpm install
- run: npm install

- run: pnpm lint
- run: npm run lint
38 changes: 14 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,16 @@ jobs:
runs-on: ubuntu-latest

steps:
# - uses: actions/checkout@v3
- uses: actions/checkout@v3

# - uses: pnpm/action-setup@v2
# with:
# version: latest
- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

# - uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: pnpm

# - run: pnpm install

# - run: pnpm test:js
- run: npm install

# - run: npm run test:js
- run: true

e2e:
Expand All @@ -36,19 +31,14 @@ jobs:
runs-on: ubuntu-latest

steps:
# - uses: actions/checkout@v3

# - uses: pnpm/action-setup@v2
# with:
# version: latest

# - uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: pnpm
- uses: actions/checkout@v3

# - run: pnpm install
- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

# - run: pnpm test:e2e
- run: npm install

# - run: npm run test:e2e
- run: true
25 changes: 25 additions & 0 deletions .github/workflows/type-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
name: Lint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

- run: npm install

- run: npm run type-check
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# system files
.DS_Store

# npm
node_modules/
npm-debug.log

# build
.cache/
build/
.env

# runtime
upload
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm lint-staged
npx lint-staged
2 changes: 0 additions & 2 deletions .lintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
pnpm-lock.yaml
/node_modules/
/.cache/
/build/
/public/build/
/media/
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM node:lts-alpine as deps

WORKDIR /app

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

FROM node:lts-alpine as production-deps

WORKDIR /app

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

FROM node:lts-alpine as build

WORKDIR /app

COPY --from=deps /app/node_modules /app/node_modules

ADD prisma .
RUN npx prisma generate

ADD . .
RUN npm run build

FROM node:lts-alpine

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

ENTRYPOINT [ "./start.sh" ]
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Festival

Festival is a website to host online music festivals. It plays the same audio
Festival is a web app to host online music festivals. It plays the same audio
file for all users at the same time based on their system clock, allowing for
the social aspect of a live broadcast (everyone can react to the same music
at the same time) without requiring live streaming infrastructure.

## Local Development

- Run `doppler setup` to set up your [Doppler](https://www.doppler.com/) config.
- Run `pnpm install` to install the required packages.
- Run `pnpm dev` to serve the application locally.
- Run `npm install` to install the required packages.
- Run `doppler run -- npm run dev` to serve the application locally.

## MySQL Setup

Expand All @@ -25,8 +25,8 @@ GRANT CREATE, ALTER, DROP, REFERENCES ON *.* TO festival@localhost;

## Building

- `pnpm build` will bundle the application for production.
- `pnpm start` will serve the bundled application.
- `npm run build` will bundle the application for production.
- `doppler run -- npm start` will serve the bundled application.

## Testing

Expand All @@ -41,10 +41,4 @@ TODO
This is required for the visualizer to work.
1. Install the
[Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli).
1. Add the following environment variables to your `.env` file:
- `FESTIVAL_SITE_DEPLOY_LOCATION`: The rsync destination for the site.
- `AZURE_STORAGE_ACCOUNT`: The name of the Azure storage account for the
media.
- `AZURE_STORAGE_KEY`: The access key for the Azure storage account.
1. Run `pnpm build` to build the site for production.
1. Run `pnpm deploy` to deploy both the site and the media.
1. Run `railway up` to build and deploy the app on Railway.
Loading

0 comments on commit 5ec890a

Please sign in to comment.