RUP University Project
Live at https://lets-watch-it-together.herokuapp.com
Read the Let's Watch It Together Wiki for more information regarding the implementation.
Check out .env.example file, you have to fill some of those environment
variables, and copy them to .env
(and create it if it doesn't exist).
This includes:
GITHUB_ID
andGITHUB_SECRET
- the GitHub OAuth app credentials for login to work,
- you may create a GitHub OAuth app yourself or contact @JakubKoralewski for those credentials
TMDB_API_KEY
- to be able to talk to TMDB API
- you need to create a TMDB account at
https://themoviedb.org
and copy thev3 auth
key fromhttps://www.themoviedb.org/settings/api
- potentially more if this README wasn't updated
This is when you have Node.js and Docker installed.
Make sure Docker is running.
Set NODE_ENV
to development
to disable PWA.
-
Install Node dependencies:
Only required first time you run, or when dependencies change.
$ npm install
-
Start PostgreSQL and Redis containers in Docker:
When you want the
docker-compose
command to run in the background:$ docker-compose up --detach
To see the output of
docker-compose
. You will need to run the commands after this one in another terminal window.$ docker-compose up
-
Run migrations:
Only required first time the database is run, or when new migrations are added.
$ npx prisma migrate dev --preview-feature
You can also add some dummy users if you want:
THIS BREAKS EVERYTHING IF THE SERVER IS RUNNING!!!
$ npm run dev-seed
-
Start the Next.js app in development mode (with live reload):
$ npm run dev
You can now start making changes to the code!
-
Tear down database and cache.
If used Option A, then once you're finished, tear down the PostgreSQL and Redis containers:
$ docker-compose down
Else just hit Ctrl+C if run Option B.
Before you commit and push a Pull Request it is a good idea to check if the tests still pass. It's also a good idea to add more tests regarding the feature you added.
To run tests once:
$ npm test
To run tests in the background as you are developing (only those tests will be run for which files have changed):
$ npx jest --watch
You can use the --watchAll
flag to rerun all tests.
See the Jest docs for more details.
If you changed the schema inside prisma/schema.prisma
you need to save those changes
as SQL migrations for other developers to replay those changes on their databases as well:
$ npx prisma migrate dev --name a-descriptive-name-of-the-thing-you-changed --preview-feature
where a-descriptive-name-of-the-thing-you-changed
is a descriptive name of the thing you changed
inside the database schema, e.g. dropped-the-database-because-its-stupid
.
Use the --create-only
flag when running migrate dev
if you want to change the generated SQL
before applying it to make some database specific changes that Prisma does not yet support.
See the Prisma Migrate documentation for more details.
To see how the containers run in production, or when you change the Dockerfile
you may want to run these commands.
Make sure you have Docker installed. Then run (to test all containers):
$ docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
To test just the web app Dockerfile
:
$ docker build . --tag lwit
To also run the above built image:
$ docker run -e PORT=3000 lwit
where 3000
is the port you want the server to run on and lwit
is
the same tag you named the image in docker build
.
To also have all the environment variables (you need to fill them in):
But this looks like it can't connect to the other Docker containers
(Postgres and Redis), so it doesn't work... try the docker-compose
command above
$ docker run -p 3000:3000 -e PORT=3000 \
-e DATABASE_URL=postgresql://postgres:postgres-dev@localhost:5432/db \
-e REDIS_URL=redis://localhost:6379 -e GITHUB_ID=PASTEHERE \
-e GITHUB_SECRET=PASTEHERE -e TMDB_API_KEY=PASTEHERE lwit
Also you can build the app to make sure it works in production:
$ NODE_ENV=production npm run build