Skip to content

Commit

Permalink
Merge pull request #68 from Black-Sirius69/go-remake
Browse files Browse the repository at this point in the history
Go Remake Base
  • Loading branch information
aditansh authored Oct 19, 2023
2 parents e0a1aa1 + 70905a7 commit ec6c5b0
Show file tree
Hide file tree
Showing 45 changed files with 859 additions and 3,933 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
npm-debug.log
postgres_data
10 changes: 6 additions & 4 deletions .example.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
DB_HOST=mongodb
DB_PORT=27017
DB_NAME=mydb
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_USER=admin
POSTGRES_PASSWORD=password123
POSTGRES_DB=icetite_backend

DB_URI = "mongodb://${DB_HOST}:${DB_PORT}/${DB_NAME}"
PORT=:8080
ACCESS_KEY_SECRET="abc"
REFRESH_KEY_SECRET="def"
JUDGE_URI=
Expand Down
30 changes: 25 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,29 @@
.vscode
.idea

# Environment
.env
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

/node_modules
.eslintrc.yml
bun.lockb
# Dependency directories (remove the comment below to include it)
# vendor/
.DS_Store
TODO.md
logs.txt
.idea/
secret.md

# Evnironment
tmp
.env
main
postgres_data/
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## icETITE-24 API

### Documentation
For detailed information on how to use the project's API, please refer to the [Postman Documentation]().


### Getting Started

Clone the repository:

``git clone https://github.com/CodeChefVIT/cookoff-backend``

Install Make, Docker and Docker Compose 2.0 if not already installed.

Run the following commands in the project root directory:

````
make help # Get All The Make Commands Supported
make build # Build Docker containers
make up # Start Docker containers in the background
````

***
Your API will be running on http://localhost/api/

Test whether API is up at http://localhost/api/ping
***
30 changes: 14 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# Use an official Node.js runtime as the base image
FROM --platform=linux/amd64 node:18
# Set the working directory inside the container
WORKDIR /usr/src/app
FROM golang:alpine

# Copy package.json and package-lock.json to the container
COPY package*.json ./
RUN apk update && apk upgrade && \
apk add --no-cache git

# Install app dependencies
RUN npm install
RUN mkdir /app

# Copy the rest of the app's source code to the container
COPY . .
WORKDIR /app

# Expose the port that the app will run on
EXPOSE 8080
ADD go.mod .
ADD go.sum .

RUN go mod download
ADD . .

# Install PM2 globally
RUN npm install pm2 -g
RUN go build -o ./bin/cookoff-backend ./cmd/main.go

EXPOSE 8080

# Use PM2 as the command to run the app, with automatic restart on failure
CMD ["pm2-runtime", "index.js"]
CMD ["./bin/cookoff-backend"]
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Define variables
DOCKER_COMPOSE = docker compose

# Targets
.PHONY: build up down logs restart clean

build:
$(DOCKER_COMPOSE) build

up:
$(DOCKER_COMPOSE) up -d

down:
$(DOCKER_COMPOSE) down

logs:
$(DOCKER_COMPOSE) logs -f

restart:
$(DOCKER_COMPOSE) restart

clean:
$(DOCKER_COMPOSE) down -v

# Help target
help:
@echo "Usage: make [target]"
@echo "Targets:"
@echo " build Build Docker containers"
@echo " up Start Docker containers in the background"
@echo " down Stop and remove Docker containers"
@echo " logs View logs of Docker containers"
@echo " restart Restart Docker containers"
@echo " clean Stop, remove containers, and also remove volumes (data)"
@echo " help Display this help message"
3 changes: 0 additions & 3 deletions allowedEmails.json

This file was deleted.

Loading

0 comments on commit ec6c5b0

Please sign in to comment.