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" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20.x]
|
||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
- run: npm run build:dev
|
||||
- run: npm run test
|
||||
|
||||
- name: Build and test with Docker Compose
|
||||
run: docker compose 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
|
||||
transit.
|
||||
This is the server codebase for Interchange, an app for college transit.
|
||||
|
||||
## Setup
|
||||
|
||||
You'll need Node.js 20.x installed to run this project.
|
||||
Clone this repository and run the following:
|
||||
You'll need Docker + Compose installed to run this project.
|
||||
Clone this repository and run one of the following:
|
||||
|
||||
```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",
|
||||
"dependencies": {
|
||||
"@apollo/server": "^4.11.2",
|
||||
"dotenv": "^16.4.7",
|
||||
"graphql": "^16.10.0",
|
||||
"jsonwebtoken": "^9.0.2"
|
||||
},
|
||||
@@ -4857,6 +4856,7 @@
|
||||
"version": "16.4.7",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz",
|
||||
"integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"start:dev": "npm run build:dev && node ./dist/index.js",
|
||||
"start": "npm run build && node ./dist/index.js",
|
||||
"generate": "graphql-codegen --config codegen.ts",
|
||||
"test": "jest"
|
||||
"test": "npm run build:dev && jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@graphql-codegen/cli": "5.0.3",
|
||||
@@ -25,7 +25,6 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@apollo/server": "^4.11.2",
|
||||
"dotenv": "^16.4.7",
|
||||
"graphql": "^16.10.0",
|
||||
"jsonwebtoken": "^9.0.2"
|
||||
}
|
||||
|
||||
@@ -6,12 +6,9 @@ import { ServerContext } from "./ServerContext";
|
||||
import { UnoptimizedInMemoryRepository } from "./repositories/UnoptimizedInMemoryRepository";
|
||||
import { TimedApiBasedRepositoryLoader } from "./loaders/TimedApiBasedRepositoryLoader";
|
||||
import { ETANotificationScheduler } from "./notifications/schedulers/ETANotificationScheduler";
|
||||
import { configDotenv } from "dotenv";
|
||||
import { loadTestData } from "./loaders/loadTestData";
|
||||
import { AppleNotificationSender } from "./notifications/senders/AppleNotificationSender";
|
||||
|
||||
configDotenv();
|
||||
|
||||
const typeDefs = readFileSync("./schema.graphqls", "utf8");
|
||||
|
||||
async function main() {
|
||||
|
||||
Reference in New Issue
Block a user