Skip to content

Commit 16ad1ca

Browse files
authored
Merge pull request #12 from csesoc/CW2-24-Setup-backend
Significant change to the fundamental structure of the repo - adding in the Express backend. Now the structure of the repo is a monorepo, with docker-compose.yml in the base directory, and subdirectories for /frontend and /backend. Implemented Dockerfiles for each frontend (port 3000) & backend (port 9000) services + Docker Compose to spin them both up Set up Express server with Routes + Controllers Created /ping endpoint to verify connection Created mock button in frontend to trigger ping Extended Github actions to include CI (type checking & building) for backend
2 parents edf4e7c + e171570 commit 16ad1ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2446
-3134
lines changed

.eslintrc.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/backend-ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Backend CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
defaults:
14+
run:
15+
working-directory: ./backend
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Use Node.js 22
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: 22
24+
25+
- name: Install dependencies
26+
run: npm install
27+
28+
- name: Check types
29+
run: npm run type-check
30+
31+
- name: Build Express app
32+
run: npm run build

.github/workflows/ci.yml renamed to .github/workflows/frontend-ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Frontend CI
22

33
on:
44
push:
@@ -10,8 +10,13 @@ jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212

13+
defaults:
14+
run:
15+
working-directory: ./frontend
16+
1317
steps:
1418
- uses: actions/checkout@v3
19+
1520
- name: Use Node.js 16
1621
uses: actions/setup-node@v3
1722
with:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

33
# dependencies
4-
/node_modules
4+
**/node_modules
55
/.pnp
66
.pnp.js
77

@@ -14,6 +14,8 @@
1414

1515
# production
1616
/build
17+
/frontend/.next
18+
/backend/dist
1719

1820
# misc
1921
.DS_Store

README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
# CSESoc Website
22

3-
## How to run locally
4-
- Install dependencies with `npm install`
5-
- Run using `npm run dev`
3+
This repository contains the code for a redesigned CSESoc website. The current website can be found at [csesoc.unsw.edu.au](https://csesoc.unsw.edu.au/).
4+
5+
## How to run locally (without Docker, development mode)
6+
7+
### Running the frontend
8+
9+
1. Navigate to the `frontend` directory with `cd frontend`.
10+
11+
2. Create a `.env` file in the `frontend` directory with the following content:
12+
```
13+
NEXT_PUBLIC_BACKEND_HOST=localhost
14+
NEXT_PUBLIC_BACKEND_PORT=9000
15+
```
16+
This is necessary for the frontend to communicate with the backend.
17+
18+
2. Install dependencies with `npm install` if you haven't already.
19+
20+
3. Run using `npm run dev`, changes will be reflected live.
21+
22+
See `package.json` for further commands to lint, build, etc.
23+
24+
25+
### Running the backend
26+
27+
1. Navigate to the `backend` directory with `cd backend`.
28+
29+
2. Install dependencies with `npm install` if you haven't already.
30+
31+
3. Run using `npm run dev`, changes will be reflected live.
32+
33+
34+
## How to run locally (with Docker, production mode)
35+
36+
Make sure you have [Docker](https://docs.docker.com/get-docker/) installed.
37+
38+
1. Run `docker compose build` in the root directory, this will build the frontend and backend services in production mode, meaning live changes will not be reflected. In the future, you will only need to run either `docker compose build frontend` or `docker compose build backend` if you have only made changes to the frontend or backend respectively.
39+
40+
2. Run `docker compose up` (or `docker compose up -d` to run in the background) in the root directory, this will start the frontend and backend services.
41+
42+
3. Run `docker compose down` to stop the services.

backend/.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
npm-debug.log
3+
build
4+
.git
5+
*.md
6+
.gitignore

backend/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:22-alpine
2+
3+
ENV NODE_ENV production
4+
5+
WORKDIR /app
6+
COPY . .
7+
8+
RUN npm ci
9+
RUN npm run build
10+
11+
EXPOSE 9000
12+
13+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)