Skip to content

Commit 5e627bf

Browse files
authored
Merge pull request #90 from TIHLDE/dev
rewrote to t3 (Mori) and added deployment to openstack (Borgar)
2 parents e5d833b + 5f755dc commit 5e627bf

File tree

169 files changed

+15747
-7470
lines changed

Some content is hidden

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

169 files changed

+15747
-7470
lines changed

.dockerignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.github
2+
.next
3+
.vscode
4+
node_modules
5+
.dockerignore
6+
.env
7+
.env.example
8+
.eslintrc.cjs
9+
.gitignore
10+
docker-compose.yml
11+
Dockerfile
12+
Makefile
13+
next-env.d.ts
14+
prettier.config.js
15+
README.md

.env-example

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# When adding additional environment variables, the schema in "/src/env.js"
2+
# should be updated accordingly.
3+
4+
DATABASE_URL="postgresql://postgres:password@localhost:5432/db"
5+
NEXTAUTH_URL="http://localhost:3000"
6+
LEPTON_API_URL="https://api.tihlde.org"
7+
ALLOWED_GROUP_SLUGS="index"
8+
NEXTAUTH_SECRET="bruh"

.eslintrc.js

-35
This file was deleted.

.eslintrc.json

-3
This file was deleted.

.github/workflows/ci.yml

-19
This file was deleted.

.github/workflows/deploy.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
types:
11+
- closed
12+
13+
14+
jobs:
15+
deploy:
16+
name: Deploy
17+
runs-on: ubuntu-latest
18+
concurrency:
19+
group: deployment_lock
20+
cancel-in-progress: false
21+
steps:
22+
- name: Checkout Code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up SSH key
26+
run: |
27+
mkdir -p ~/.ssh
28+
echo "${{ secrets.KEY }}" > ~/.ssh/key
29+
chmod 600 ~/.ssh/key
30+
ssh-keyscan ${{ secrets.HOST }} >> ~/.ssh/known_hosts
31+
32+
- name: Create .env file
33+
run: |
34+
echo 'DATABASE_URL="${{ secrets.DATABASE_URL }}"' >> .env
35+
echo 'NEXTAUTH_URL="${{ secrets.NEXTAUTH_URL }}"' >> .env
36+
echo 'NEXT_PUBLIC_LEPTON_API_URL="${{ secrets.NEXT_PUBLIC_LEPTON_API_URL }}"' >> .env
37+
echo 'ALLOWED_GROUP_SLUGS="${{ secrets.ALLOWED_GROUP_SLUGS }}"' >> .env
38+
echo 'NEXTAUTH_SECRET="${{ secrets.NEXTAUTH_SECRET }}"' >> .env
39+
40+
- name: Copy .env to OpenStack server
41+
run: |
42+
scp -v -i ~/.ssh/key .env ${{ secrets.USER }}@${{ secrets.HOST }}:${{ secrets.PATH }}
43+
44+
- name: Deploy to OpenStack server
45+
run: |
46+
ssh -v -i ~/.ssh/key ${{ secrets.USER }}@${{ secrets.HOST }} << 'ENDSSH'
47+
cd ${{ secrets.PATH }}
48+
chmod 0600 .env
49+
git pull
50+
make prod
51+
ENDSSH

.gitignore

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44
/node_modules
55
/.pnp
66
.pnp.js
7+
package-lock.json
78

89
# testing
910
/coverage
1011

12+
# database
13+
/prisma/db.sqlite
14+
/prisma/db.sqlite-journal
15+
db.sqlite
16+
1117
# next.js
1218
/.next/
1319
/out/
20+
next-env.d.ts
1421

1522
# production
1623
/build
@@ -23,16 +30,21 @@
2330
npm-debug.log*
2431
yarn-debug.log*
2532
yarn-error.log*
33+
.pnpm-debug.log*
2634

2735
# local env files
28-
.env*.local
36+
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
2937
.env
38+
.env*.local
39+
3040
# vercel
3141
.vercel
3242

3343
# typescript
3444
*.tsbuildinfo
35-
next-env.d.ts
3645

37-
#
46+
# idea files
3847
.idea
48+
49+
# ER
50+
ER_diagram.pdf

.prettierrc

-7
This file was deleted.

.vscode/controller.code-snippets

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
// Place your Blitzed workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
3+
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
4+
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
5+
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
6+
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
7+
// Placeholders with the same ids are connected.
8+
// Example:
9+
// "Print to console": {
10+
// "scope": "javascript,typescript",
11+
// "prefix": "log",
12+
// "body": [
13+
// "console.log('$1');",
14+
// "$2"
15+
// ],
16+
// "description": "Log output to console"
17+
// }
18+
"Endpoint controller" :{
19+
"scope": "typescript",
20+
"prefix": "con",
21+
"body": [
22+
"import { Controller } from '~/server/api/trpc';",
23+
"",
24+
"import { db } from '~/server/db';",
25+
"import { z } from 'zod';",
26+
"import { protectedProcedure } from '~/server/api/trpc'",
27+
"",
28+
"const InputSchema = z.object({",
29+
" ${2: input type}",
30+
"});",
31+
"",
32+
"const OutputSchema = z.object({",
33+
" ${3: output type}",
34+
"});",
35+
"",
36+
"const handler: Controller<",
37+
"z.infer<typeof InputSchema>,",
38+
"z.infer<typeof OutputSchema>",
39+
"> = async ({ input, ctx }) => {",
40+
" $0",
41+
"};",
42+
"",
43+
"export default protectedProcedure",
44+
".input(InputSchema)",
45+
".output(OutputSchema)",
46+
".${1:mutation or query}(handler);",
47+
],
48+
"description": "Create a new tRPC endpoint controller"
49+
}
50+
}
51+

Dockerfile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM node:current-alpine AS build
2+
3+
RUN apk add openssl
4+
5+
WORKDIR /build
6+
7+
COPY . .
8+
9+
RUN npm install -g pnpm
10+
11+
RUN pnpm i --frozen-lockfile
12+
13+
ENV SKIP_ENV_VALIDATION=1
14+
15+
RUN pnpm build
16+
17+
FROM node:current-alpine AS runner
18+
19+
WORKDIR /app
20+
21+
RUN apk add openssl
22+
# Prisma is used in prod deployment
23+
RUN npm install -g prisma
24+
25+
COPY --from=build /build/.next/standalone ./
26+
RUN rm -f .env
27+
COPY --from=build /build/.next/static ./.next/static/
28+
COPY --from=build /build/prisma ./prisma/
29+
COPY --from=build /build/public ./public/
30+
31+
EXPOSE 3000
32+
ENV PORT=3000
33+
34+
ENV NEXT_TELEMETRY_DISABLED=1
35+
36+
CMD [ "node", "server.js" ]

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.PHONY: db
2+
db:
3+
docker compose up -d
4+
5+
.PHONY: prod
6+
prod:
7+
docker build -t blitzed:latest .
8+
docker container stop blitzed
9+
docker container rm blitzed
10+
- prisma migrate deploy
11+
docker run --env-file .env -p 4000:3000 --name blitzed -d blitzed:latest

README.md

+28-21
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
1-
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
1+
# Blitzed
22

3-
## Getting Started
3+
Blitzed er TIHLDE's nettside for drikkeleker!
44

5-
First, run the development server:
5+
For å starte:
6+
7+
### 1. Klon repoet
68

79
```bash
8-
npm run dev
9-
# or
10-
yarn dev
11-
# or
12-
pnpm dev
13-
# or
14-
bun dev
10+
git clone [email protected]:TIHLDE/Blitzed.git
1511
```
1612

17-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
13+
### 2. Installer pakker
1814

19-
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
15+
```bash
16+
pnpm i
17+
```
2018

21-
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
19+
### 3. Sett opp miljøvariabler
20+
21+
```bash
22+
cp .env-example .env
23+
```
2224

23-
## Learn More
25+
### 3. Sett opp database
2426

25-
To learn more about Next.js, take a look at the following resources:
27+
Pass på at Docker kjører på pc-en din
2628

27-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
```
30+
make db
31+
```
2932

30-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
33+
Deretter kjør migreringer på den
3134

32-
## Deploy on Vercel
35+
```
36+
npx prisma migrate dev
37+
```
3338

34-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
39+
### 4. Kjør prosjektet
3540

36-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
41+
```
42+
pnpm dev
43+
```

0 commit comments

Comments
 (0)