Webpage for AscendNTNU
This is the webpage for Ascend NTNU.
- Guidelines for changing code
- Setup dev environment
- Deploy, Production
- Run in Docker (Because it only works)
We have some rules when changing code:
- Use braches! Every time someone pushes to
dev
branch, a new website is build from ground up.dev
branch is for staging so you can see the result on dev.ascendntnu.no. - Use Pull Requests. We need to review code, and making sure things are working. Do not merge to
dev
without a PR. - Test everything. The site is made for mobile and desktop. Please test both before lauching to
dev
and creating a release (tag). - Comment code. We use Standard JS.
To set up the developent environment, follow the instructions below.
You should have node.js
installed with npm
. Just go to their website and download. Any version should work.
If you are a Ascend NTNU member, we will give you access to content belonging to the project. If you have access, run:
make download-images
There are also plenty of ways to download content from the server. Just find a way to copy the content from the public/images/assets
and public/images/teams
folder. The make
command above is the easiest one.
Now that the resources is in place, run: (This is the most important step)
# Installing dependencies.
$ npm install
# Run a static file server:
$ npm run server # This runs the server at localhost:8080 (default)
# Hot-reloading (live refresh) while developing:
$ npm start # This should open the project in the browser at localhost:8081 (default)
Most production environments like to use their own set of environment variables to control the state. We therefore have an option for adding environment variables. You can either:
- Change a env var before the server starts. Linux:
NODE_ENV=production npm run ...
- Or add them to a
.env.local
file. Format (and defaults) are set in.env
.
Our docker-compose transfers NODE_ENV
into the containers.
If you have docker-compose
(which should follow the docker installation), you only need these commands:
# Run server on localhost:8080 (port set by DOCKER_PORT)
$ docker-compose run build # To build in production used by server
$ docker-compose up server
# Run development on localhost:8081 (port set by DOCKER_DEV_PORT)
$ docker-compose up dev # This also starts the API at localhost:8082
# Run API on localhost:8082 (port set by DOCKER_API_PORT)
$ docker-compose run api python manage.py createsuperuser # Create a super user
$ docker-compose up api # Run in background mode by adding -d (detach).
# Use .env.local and .env.production.local files to control the ports.
Read more about docker-compose
on the Internet if you want to learn more neat commands.