Skip to content

Commit

Permalink
Started conversion to golang
Browse files Browse the repository at this point in the history
  • Loading branch information
RustyDev69 committed Oct 4, 2023
1 parent e0a1aa1 commit 10f06a7
Show file tree
Hide file tree
Showing 42 changed files with 260 additions and 3,933 deletions.
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:80

Test whether API is up at http://localhost/api/v1/healthcheck
***
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 10f06a7

Please sign in to comment.