Skip to content
Open
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
8 changes: 8 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DATABASE_URL="postgresql://postgres:1234@db:5432/skku?schema=public"
PORT=4000
SESSION_SECRET=ASD3FCV3XDSI5MVQWR643LKW23EQFLM
MINIO_PORT=9000
MINIO_END_POINT=ejp-minio
MINIO_ACCESS_KEY=skku-ejs
MINIO_SECRET_KEY=12345678
MINIO_BUCKET_NAME=test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/dist
/node_modules
.pnpm-store
.env


#minio config
.minio.sys
Expand Down
143 changes: 70 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,70 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Installation

```bash
$ pnpm install
```

## Running the app

```bash
# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod
```

## Test

```bash
# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov
```

## Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)

## License

Nest is [MIT licensed](LICENSE).
# EJP-BE: Edged Judger Platform Backend Server 🍎

EJS-Be is a nestJs-based backend server that enables EJP ecosystem. In order for EJS-S and EJS-T to function properly, instructors need to deploy this server in the environment of their choice. EJS-Be operates within a Docker Engine-based container environment.

## Table of Contents

- [Highlights 🌟](#highlights-🌟)
- [Getting Started 📚](#getting-started-📚)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [How it Works](#HowitWorks)
- [Contributing 🤝](#contributing-🤝)
- [License 📄](#license-📄)

## Highlights 🌟

- **Container Based**: As long as Docker is installed, the server can be run in any environment..
- **User adminstration System**: Granting permissions to users for repositories and problems ensures that only users with those specific permissions can access them.

## Getting Started 📚

### Prerequisites

- Requires Docker Engine installed

### Installation

1. Clone the EJP-Be repository.
```bash
git clone https://github.com/EdgeCrafters/ejp-be.git
```
2. Navigate to the cloned directory and build ejs-be image.
```bash
cd ejp-be
docker-compose -f docker-compose.prod.yml build
```

### Usage

1. run docker-compose container
```bash
docker-compose -f docker-compose.prod.yml up -d
```

default tutor authentication
id: tutor01
password: 1234

default student authentication
id: student01
password: 1234

## Contributing 🤝

We welcome contributions from the community! Feel free to fork the repository, make your changes, and submit a pull request. For more details, check out our [contribution guidelines](#).

## License 📄

EJP-Be is part of the EJP project and follows the same MIT license.

## HowitWorks

EJP-Be is composed of a total of four containers. EJP-Be, EJP-Minio, and EJP-db communicate through a dedicated container network established using docker-compose.

1. EJP-be
2. EJP-db
EJP-db serves as a PostgreSQL-based database that stores user information, user repository details, and metadata information about problems and repositories.
3. EJP-minio

4. EJP-minio-mc
44 changes: 21 additions & 23 deletions builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# USAGE `docker build -f builder/Dockerfile .`

### BUILDER ###
FROM node:18-alpine AS builder

COPY . /build
WORKDIR /build

RUN npm install -g pnpm
RUN pnpm install

RUN npx prisma generate
RUN npm run build

EXPOSE 4000

### PRODUCTION ###
FROM node:18-alpine

ENV NODE_ENV=production
COPY --from=builder /build .
COPY ./builder/entrypoint.sh .

# USAGE `docker build -f builder/Dockerfile .`

### BUILDER ###
FROM node:18-alpine AS builder

COPY . /build
WORKDIR /build

RUN npm install -g pnpm
RUN pnpm install

RUN npx prisma generate
RUN npm run build

### PRODUCTION ###
FROM node:18-alpine

ENV NODE_ENV=production
COPY --from=builder /build .
COPY ./builder/entrypoint.sh .

ENTRYPOINT ["./entrypoint.sh"]
30 changes: 15 additions & 15 deletions builder/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
*

!src
!prisma
!package.json
!pnpm-lock.yaml
!builder/entrypoint.sh
!nest-cli.json
!tsconfig.build.json
!tsconfig.json
!.swcrc
!.npmrc

dist
.env
*
!src
!prisma
!package.json
!pnpm-lock.yaml
!builder/entrypoint.sh
!nest-cli.json
!tsconfig.build.json
!tsconfig.json
!.swcrc
!.npmrc
dist
!.env
.env.*
1 change: 1 addition & 0 deletions builder/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
npx prisma migrate deploy
npx prisma db seed
node dist/src/main.js
45 changes: 45 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: '3'

services:
server:
container_name: ejp-be
build:
dockerfile: ./builder/Dockerfile
ports:
- 4000:4000
stdin_open: true
tty: true
depends_on:
- db
db:
container_name: ejp-db
image: postgres:14-alpine
expose:
- '5432'
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1234
POSTGRES_DB: skku
minio:
container_name: ejp-minio
image: minio/minio
command: server /data --console-address ":9001"
expose:
- '9001'
- '9000'
environment:
MINIO_ROOT_USER: skku-ejs
MINIO_ROOT_PASSWORD: 12345678

mcservice:
container_name: ejp-minio-mc
image: minio/mc
restart: on-failure
depends_on:
- minio
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio http://ejp-minio:9000 skku-ejs 12345678;
/usr/bin/mc mb myminio/test;
/usr/bin/mc policy set public myminio/test;
"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@
"typescript": "^5.1.3"
},
"prisma": {
"seed": "swc-node prisma/seed.ts"
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
}
}