mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
Merge pull request #34 from brendan-ch/chore/setup-docker-and-redis
chore/setup-docker-and-redis
This commit is contained in:
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
18
.github/workflows/test.yml
vendored
18
.github/workflows/test.yml
vendored
@@ -7,21 +7,11 @@ on:
|
|||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [20.x]
|
|
||||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
|
||||||
uses: actions/setup-node@v4
|
- name: Build and test with Docker Compose
|
||||||
with:
|
run: docker compose run test
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
cache: 'npm'
|
|
||||||
- run: npm run build:dev
|
|
||||||
- run: npm run test
|
|
||||||
|
|||||||
4
Dockerfile
Normal file
4
Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM node:20-alpine
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
COPY . .
|
||||||
|
EXPOSE 4000
|
||||||
22
README.md
22
README.md
@@ -1,17 +1,19 @@
|
|||||||
# Interchange Node.js Server
|
# Interchange Server
|
||||||
|
|
||||||
This is the server codebase for Interchange, an app for college
|
This is the server codebase for Interchange, an app for college transit.
|
||||||
transit.
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
You'll need Node.js 20.x installed to run this project.
|
You'll need Docker + Compose installed to run this project.
|
||||||
Clone this repository and run the following:
|
Clone this repository and run one of the following:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm start:dev
|
# run the standard Node development server and Redis
|
||||||
|
$ docker compose run dev
|
||||||
|
|
||||||
|
# run with unit/server integration tests
|
||||||
|
$ docker compose run test
|
||||||
|
|
||||||
|
# run with test data suitable for app integration tests
|
||||||
|
$ docker compose run app-integration-tests
|
||||||
```
|
```
|
||||||
|
|
||||||
This will run `npm install`, generate GraphQL type definitions,
|
|
||||||
and start the server in developer mode.
|
|
||||||
|
|
||||||
|
|||||||
54
docker-compose.yml
Normal file
54
docker-compose.yml
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# Note that .env file will automatically populate
|
||||||
|
# variables in this file.
|
||||||
|
# If these variables are also set on the host system,
|
||||||
|
# those will be used over the .env file.
|
||||||
|
# See https://vsupalov.com/docker-arg-env-variable-guide/
|
||||||
|
|
||||||
|
x-common-environment: &common-server-environment
|
||||||
|
APNS_IS_PRODUCTION: ${APNS_IS_PRODUCTION}
|
||||||
|
APNS_BUNDLE_ID: ${APNS_BUNDLE_ID}
|
||||||
|
APNS_TEAM_ID: ${APNS_TEAM_ID}
|
||||||
|
APNS_KEY_ID: ${APNS_KEY_ID}
|
||||||
|
APNS_PRIVATE_KEY: ${APNS_PRIVATE_KEY}
|
||||||
|
REDIS_URL: redis://redis:6379
|
||||||
|
|
||||||
|
services:
|
||||||
|
dev:
|
||||||
|
build: .
|
||||||
|
command: npm run start:dev
|
||||||
|
ports:
|
||||||
|
- "4000:4000"
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
environment:
|
||||||
|
<<: *common-server-environment
|
||||||
|
volumes:
|
||||||
|
- .:/usr/src/app
|
||||||
|
|
||||||
|
app-integration-test:
|
||||||
|
build: .
|
||||||
|
command: npm run start:dev integration-testing
|
||||||
|
ports:
|
||||||
|
- "4000:4000"
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
environment:
|
||||||
|
<<: *common-server-environment
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- .:/usr/src/app
|
||||||
|
|
||||||
|
test:
|
||||||
|
build: .
|
||||||
|
command: npm run test
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
environment:
|
||||||
|
<<: *common-server-environment
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- .:/usr/src/app
|
||||||
|
redis:
|
||||||
|
image: redis:alpine
|
||||||
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -9,7 +9,6 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/server": "^4.11.2",
|
"@apollo/server": "^4.11.2",
|
||||||
"dotenv": "^16.4.7",
|
|
||||||
"graphql": "^16.10.0",
|
"graphql": "^16.10.0",
|
||||||
"jsonwebtoken": "^9.0.2"
|
"jsonwebtoken": "^9.0.2"
|
||||||
},
|
},
|
||||||
@@ -4857,6 +4856,7 @@
|
|||||||
"version": "16.4.7",
|
"version": "16.4.7",
|
||||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz",
|
||||||
"integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==",
|
"integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==",
|
||||||
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"start:dev": "npm run build:dev && node ./dist/index.js",
|
"start:dev": "npm run build:dev && node ./dist/index.js",
|
||||||
"start": "npm run build && node ./dist/index.js",
|
"start": "npm run build && node ./dist/index.js",
|
||||||
"generate": "graphql-codegen --config codegen.ts",
|
"generate": "graphql-codegen --config codegen.ts",
|
||||||
"test": "jest"
|
"test": "npm run build:dev && jest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@graphql-codegen/cli": "5.0.3",
|
"@graphql-codegen/cli": "5.0.3",
|
||||||
@@ -25,7 +25,6 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/server": "^4.11.2",
|
"@apollo/server": "^4.11.2",
|
||||||
"dotenv": "^16.4.7",
|
|
||||||
"graphql": "^16.10.0",
|
"graphql": "^16.10.0",
|
||||||
"jsonwebtoken": "^9.0.2"
|
"jsonwebtoken": "^9.0.2"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,9 @@ import { ServerContext } from "./ServerContext";
|
|||||||
import { UnoptimizedInMemoryRepository } from "./repositories/UnoptimizedInMemoryRepository";
|
import { UnoptimizedInMemoryRepository } from "./repositories/UnoptimizedInMemoryRepository";
|
||||||
import { TimedApiBasedRepositoryLoader } from "./loaders/TimedApiBasedRepositoryLoader";
|
import { TimedApiBasedRepositoryLoader } from "./loaders/TimedApiBasedRepositoryLoader";
|
||||||
import { ETANotificationScheduler } from "./notifications/schedulers/ETANotificationScheduler";
|
import { ETANotificationScheduler } from "./notifications/schedulers/ETANotificationScheduler";
|
||||||
import { configDotenv } from "dotenv";
|
|
||||||
import { loadTestData } from "./loaders/loadTestData";
|
import { loadTestData } from "./loaders/loadTestData";
|
||||||
import { AppleNotificationSender } from "./notifications/senders/AppleNotificationSender";
|
import { AppleNotificationSender } from "./notifications/senders/AppleNotificationSender";
|
||||||
|
|
||||||
configDotenv();
|
|
||||||
|
|
||||||
const typeDefs = readFileSync("./schema.graphqls", "utf8");
|
const typeDefs = readFileSync("./schema.graphqls", "utf8");
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user