Skip to content

Codemmunity-io/Codemmunity_Backend

Repository files navigation

Codemmunity Backend

This is the backend repository for the codemmunity website project. Being built with NodeJs Express and a MYSQL Database.

Table of contents

Quick start

This branch contains the basic boilerplate for an ExpressJs/NodeJs environment. Here is how to set it up on your machine:

  • Pull the most recent code by running git pull in your terminal
  • Run the setup shell scripts for your operating system (.ps1 is powershell)
  • Run node app.js to start the server
  • You can use npm run dev command for the server to update dynamically with file changes

Docker

Get Docker here

To build the image with Docker run:

docker build  -t codemmunity_backend/codemmunity_backend .

docker build - use docker to build

-t codemmunity_backend/codemmunity_backend - tag it <ImageName>/<ImageTag>

. - using the Dockerfile in the current directory

This will build it using environment variables in the .env file


To run the Docker Image:

docker run -p 8080:8080  -t codemmunity/codemmunity_backend -d

docker run - run a docker image

-p 8080:8080 - expose port 8080 of the container to 8080 of your machine

-t codemmunity_backend/codemmunity_backend - with this name

-d - run container in background, detatch


To see your running docker containers run:

docker ps

To stop a container run:

docker container stop <First 2 or more characters of the containerID>

To remove a container run:

docker container rm <First 2 or more characters of the containerID>

Docker-Compose

Get Docker Compose here

Ensure your environment variables are set in your .env file

To start MYSQL Container with docker-compose:

cd docker
docker-compose --env-file ../.env up -d

docker-compose [..] up - start the docker compose services

--env-file ../.env - use the environment variables from our .env file in the root directory

-d - detatch, run in the background


To stop MYSQL Container:

docker-compose --env-file ../.env down

Issues

WARNING: The {VarName} variable is not set. Defaulting to a blank string.

If you see an error like this

Your .env file is not configured properly. Please make sure it matches the format in .env.example

Or

The path to your .env file is incorrect, ensure the .env file is in the project root directory, and you're running docker-compose from within docker folder.

Getting started with collaboration on github

Clone the Repo

clone the repository

git clone git@github.com:rohit0110/Codemmunity_Backend.git

then enter the repo directory

cd Codemmunity_Backend

Sync local repo with github

Pull any changes

git pull

Local status

To see the current status of your local repo run:

git status

This will tell you any changes made that need to be added and committed.

Branches

Before you begin work on a new feature, create a new branch to work on:

git branch <Branch name>

Then switch to that branch

git checkout <Branch name>

To see the list of branches, and your current branch, run:

git branch

Committing changes

Once you have made your changes, add them to git

git add .

And commit the changes:

git commit -m "Commit message"

The commit message should be short but also explain the changes.

Then push your changes to the branch on github

git push

The first time you push a branch you will see an error with a command suggestion

fatal: The current branch github_docs has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin <branch name>

Copy the command and run it

To change back to the main branch run:

git checkout main

Forgot to make a new branch before making changes?

Stash your changes

git stash

This will safely store your changes and revert to the last pull

Follow the steps to create a new branch.

Then to get your changes back run:

git stash pop

Discord Link

Codemmunity Discord

About

Backend for the codemmunity project

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •