Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
JWT_SECRET_KEY="something"
FRONTEND_URL="http://localhost:8081"
API_URL="http://localhost:8080"

SMTP_HOST=""
Expand Down
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: 'Bug: '
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Device**
Did it happen on Mobile, Tablet, Desktop...
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature Request
about: Suggest an idea for this project
title: 'Feature Request:'
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
35 changes: 35 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch: {}

jobs:

build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23.0'

- name: Generate GraphQL code
run: go generate ./...

- name: Build
run: go build -v ./...

# - name: Test
# run: go test -v ./...
46 changes: 46 additions & 0 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Test Next.js

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
node-version:
description: |
Manually run the workflow. The node.js version to use can be specified.
If not specified, the default is 20.x
default: '20.x'

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

defaults:
run:
working-directory: ./frontend

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Build project
run: npm run build

# - name: Run tests
# run: npm test
78 changes: 78 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build & Publish Docker Image

on:
release:
types: [published]

push:
branches:
- main

workflow_dispatch: {}

permissions:
contents: read
packages: write
id-token: write

env:
IMAGE_NAME: fachschaftmathphysinfo/cards
REGISTRY: ghcr.io

jobs:
testing:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
name: Build & Push “testing” Tag

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build & tag as testing
run: |
IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker build -t $IMAGE:testing .

- name: Push testing tag
run: |
IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker push $IMAGE:testing

release:
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
name: Build & Push Release Tags

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine release tag
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Build & tag Docker image
run: |
IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker build -t $IMAGE:${{ env.RELEASE_TAG }} .
docker tag $IMAGE:${{ env.RELEASE_TAG }} $IMAGE:latest

- name: Push release images
run: |
IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker push $IMAGE:${{ env.RELEASE_TAG }}
docker push $IMAGE:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

deckfiles/
metadata/
storage/

# Miscellaneous
*.class
Expand Down
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
############################################
# Build the Next.js frontend
############################################
FROM node:20-alpine AS frontend-build

WORKDIR /app

COPY frontend/package*.json ./
COPY frontend/tsconfig.json ./

RUN npm install
COPY frontend/ .
RUN npm run build


############################################
# Build the Go GraphQL server
############################################
FROM golang:1.23.0-bullseye AS server-build

WORKDIR /go/src

COPY server/go.mod server/go.sum ./
RUN go mod download

COPY server/ .
RUN go generate ./...
RUN CGO_ENABLED=0 go build -a -o graphql-server server.go


############################################
# Final image
############################################
FROM node:20-alpine AS final

WORKDIR /app

COPY --from=frontend-build /app/package*.json ./
COPY --from=frontend-build /app/.next ./.next
COPY --from=frontend-build /app/public ./public
RUN mkdir -p ./storage/deckfiles

RUN npm install --production

COPY --from=server-build /go/src/graphql-server /usr/local/bin/graphql-server
EXPOSE 8080

CMD ["sh", "-c", "\
graphql-server & \
npm start \
"]
37 changes: 7 additions & 30 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
version: '3'

---
volumes:
metadata:
deckfiles:
data:

services:
database:
image: mongo
volumes:
- ./metadata/:/data/db
command: mongod --quiet --logpath /dev/null

server:
build:
context: ./server
dockerfile: Dockerfile
env_file: .env
volumes:
- ./deckfiles/:/deckfiles
stapel:
build: .
image: cards:latest
ports:
- 8080:8080
depends_on:
- database

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
- API_URL=${API_URL}
env_file: .env
ports:
- 8081:80
depends_on:
- server
volumes:
- ./data:/app/storage
41 changes: 41 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

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.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Loading
Loading