-
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.
- Loading branch information
Showing
28 changed files
with
991 additions
and
427 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,16 @@ | ||
# Node Modules | ||
node_modules | ||
|
||
# Cache | ||
.firebase | ||
|
||
# Secrets | ||
.env | ||
.data | ||
|
||
# Test Logs | ||
test.*.log | ||
tap.info | ||
|
||
# OS Files | ||
.DS_Store |
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,9 +1,18 @@ | ||
.glitchdotcom.json | ||
.node-gyp | ||
# Third Party | ||
node_modules | ||
.data | ||
.DS_Store | ||
.env | ||
public/lib | ||
migrations | ||
|
||
# Cache | ||
.firebase | ||
|
||
# Secrets | ||
.env | ||
.data | ||
|
||
# Test Logs | ||
test.*.log | ||
tap.info | ||
tap.info | ||
|
||
# OS Files | ||
.DS_Store |
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,9 +1,16 @@ | ||
.glitchdotcom.json | ||
.node-gyp | ||
# Node Modules | ||
node_modules | ||
.data | ||
.DS_Store | ||
.env | ||
|
||
# Cache | ||
.firebase | ||
|
||
# Secrets | ||
.env | ||
.data | ||
|
||
# Test Logs | ||
test.*.log | ||
tap.info | ||
tap.info | ||
|
||
# OS Files | ||
.DS_Store |
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,10 +1,22 @@ | ||
.glitchdotcom.json | ||
.node-gyp | ||
# Third Party | ||
node_modules | ||
.data | ||
.DS_Store | ||
.env | ||
public/lib | ||
migrations | ||
server/super_admin | ||
|
||
# Minified Files | ||
**/*.min.js | ||
|
||
# Cache | ||
.firebase | ||
|
||
# Secrets | ||
.env | ||
.data | ||
|
||
# Test Logs | ||
test.*.log | ||
tap.info | ||
**/*.min.js | ||
|
||
# OS Files | ||
.DS_Store |
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,46 @@ | ||
# syntax = docker/dockerfile:1 | ||
|
||
# Adjust NODE_VERSION as desired | ||
ARG NODE_VERSION=18.17.0 | ||
FROM node:${NODE_VERSION}-slim as base | ||
|
||
LABEL fly_launch_runtime="Node.js" | ||
|
||
# Node.js app lives here | ||
WORKDIR /app | ||
|
||
# Set production environment | ||
ENV NODE_ENV="production" | ||
|
||
|
||
# Throw-away build stage to reduce size of final image | ||
FROM base as build | ||
|
||
# Install packages needed to build node modules | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 | ||
|
||
# Install node modules | ||
COPY --link package-lock.json package.json ./ | ||
RUN npm ci | ||
|
||
# Copy application code | ||
COPY --link . . | ||
|
||
|
||
# Final stage for app image | ||
FROM base | ||
|
||
# Copy built application | ||
COPY --from=build /app /app | ||
|
||
# Setup a volume for data storage | ||
RUN mkdir -p /data | ||
VOLUME /data | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 3000 | ||
ENV PORT=3000 | ||
ENV DB_FILE="/data/sqlite.db" | ||
ENV ATT_CODE_DIR="/data/att_codes" | ||
CMD [ "npm", "run", "start" ] |
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 |
---|---|---|
|
@@ -18,47 +18,45 @@ URL: https://attendancescannerqr.web.app | |
|
||
## Branches | ||
|
||
- `master` - production branch - clone of Glitch branch (Glitch is currently used for hosting the server) | ||
- `main` - main development branch - latest stable version of the code, hosted on Github | ||
|
||
## Local Development | ||
|
||
### Setup | ||
|
||
1. `git clone https://github.com/clr-li/AttendanceScanner.git` | ||
2. `git remote add glitch [INSERT GLITCH API URL HERE AND REMOVE THESE BRACKETS]` | ||
3. Add the `.data` directory and `.env` file (can be found on Glitch) | ||
- These are already `.gitignore`'d to avoid leaking API keys and secrets and user data | ||
4. `npm ci` to install the necessary dependencies from the package lock | ||
5. `npm run dev` (this will run the local server using the local .env file; `npm start` is only for Glitch) | ||
- After running `npm run dev`, use a browser to go to the localhost port printed (this should automatically open on most systems) | ||
2. Add the `.data` directory and `.env` file | ||
- These are `.gitignore`'d to avoid leaking API keys, secrets and user data | ||
3. `npm ci` to install the necessary dependencies from the package lock | ||
4. `npm run dev` (this will run the local server using the local .env file; `npm start` is only for production) | ||
5. Use a browser to go to the localhost port printed (this should automatically open on most systems) | ||
|
||
### Workflow | ||
### Common Commands | ||
|
||
0. Start with `git pull`, and make sure you are on the right branch, e.g. `git checkout main` | ||
|
||
For small changes: | ||
|
||
1. Make changes to the local `main` branch | ||
2. `git add` and `git commit` any changes locally | ||
3. `git push origin` to push to the Github `main` branch | ||
|
||
For larger changes: | ||
|
||
1. `git checkout -b [NAME OF NEW DEVELOPMENT BRANCH]` to create a separate branch | ||
2. Make changes and `git add` and `git commit` locally | ||
3. `git push origin` and create a pull request for others to review and merge into `main` after review | ||
|
||
Then to deploy Github `main` to Glitch and Firebase:<br> | ||
4. `npm run deploy`<br> | ||
- Or to only deploy to Glitch: `npm run glitch`<br> | ||
- Or to only deploy static files to Firebase: `npm run fire` | ||
- To run the server locally: `npm run dev` | ||
- To run formatting and build fonts and other resources: `npm run build` | ||
- To run tests and linting: `npm test` | ||
- To deploy both server and static files: `npm run deploy` | ||
- To only deploy static files: `npm run deploy:fire` | ||
- To run the server locally with production settings: `npm run docker:build && npm run docker:run` | ||
|
||
### Update database | ||
|
||
- To update the database schema, change the `schema.sql` file accordingly (note this file should only contain DDL statements). If you are running the `npm run dev` server, a new migration file will automatically be created in the `migration` folder and applied locally. Otherwise, you can run `sam make` to create it and `sam migrate` to apply it locally. Run `sam status` to verify your changes and optionally inspect the autocreated migration file. Once you are satisfied everything is in order, `npm run deploy` changes like normal and the production server will automatically apply the new migration file. | ||
- To purge the Braintree payment vault test data, login to the Braintree sandbox, click the gear icon and select "Purge Test Data" | ||
|
||
### Manage Deployment | ||
|
||
- Configure server: [fly.io](https://fly.io/apps/attendqr) | ||
- [Memory usage and requests dashboard](https://fly-metrics.net/d/fly-app/fly-app?orgId=726754) | ||
- [View logs](https://fly-metrics.net/d/fly-logs/fly-logs?orgId=726754&var-app=attendqr) | ||
- Configure firebase: [firebase console](https://console.firebase.google.com/u/0/project/attendancescannerqr/overview) | ||
- [Configure auth](https://console.firebase.google.com/u/0/project/attendancescannerqr/authentication/users) | ||
- [Docs for static file hosting](https://firebase.google.com/docs/hosting) | ||
- Configure Braintree: [sandbox](https://sandbox.braintreegateway.com/login) | ||
- [Docs for testing](https://developers.braintreepayments.com/start/hello-server/node) | ||
- [Docs for production](https://developer.paypal.com/braintree/docs/start/go-live/node) | ||
|
||
## Automated Testing | ||
|
||
1. Before running tests, run `npm install` (freshly installs dependencies from package.json) or `npm ci` (install specific dependency versions from package-lock) to make sure dependencies are installed. | ||
|
@@ -90,7 +88,3 @@ We use [Selenium](https://www.npmjs.com/package/selenium-webdriver) for cross br | |
#### Setup Tests of the OAuth Flow | ||
|
||
By default tests mock the Firebase Authentication layer (to run faster and not require storing Google account credentials). To test with a real Google account, run tests with an account email (`[email protected]`) and password (`TEST_PASSWORD=xxxx`) in the `.env` file. The tests will attempt to automatically login for these test, but they may still require manual input during the login phase if your account has MFA enabled or other security settings that interfere. Currently only supported for Google Chrome. | ||
|
||
## Glitch Development | ||
|
||
We should not edit directly on Glitch except to change .gitignored content like the production `.data` or `.env`. If the changes only apply to Glitch and not local development, just change directly. Otherwise, make sure leave a note somewhere. |
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,26 @@ | ||
# fly.toml app configuration file generated for attendqr on 2024-04-13T17:42:28-07:00 | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = 'attendqr' | ||
primary_region = 'sea' | ||
|
||
[build] | ||
|
||
[[mounts]] | ||
source = 'data' | ||
destination = '/data' | ||
|
||
[http_service] | ||
internal_port = 3000 | ||
force_https = true | ||
auto_stop_machines = true | ||
auto_start_machines = true | ||
min_machines_running = 0 | ||
processes = ['app'] | ||
|
||
[[vm]] | ||
memory = '1gb' | ||
cpu_kind = 'shared' | ||
cpus = 1 |
Oops, something went wrong.