Giter Site home page Giter Site logo

yolkmonday / cybersim-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nditech/cybersim-backend

1.0 0.0 0.0 2.05 MB

An application for aiding facilitation of the CyberSim cybersecurity exercise

License: Other

JavaScript 99.86% Dockerfile 0.09% Shell 0.06%

cybersim-backend's Introduction

ndi-cybersim-api

Postgres docker image

Start postgres docker: docker-compose up -d

Stop postgres docker: docker-compose down

Reset db (unmigrate => migrate => seed): npm run reset-db

  • Migrate tables: npm run migrate

  • Rollback tables: npm run unmigrate

  • Seed NDI table: npm run seed

Run test: npm run test

Start API: npm run start

To set up the project on your local environment run the following commands:

# Clone the project by running git clone.
$ git clone <REPO_LINK>
# Install the node dependencies by running
$ npm install
# Create a .env file based on .env.example
$ cp .env.example .env
# Start Postgres and Adminer by running
$ docker-compose up -d
# Start the API on localhost:3001 (if nothing changed in .env.example)
$ npm start

For some basic source code explanation see the wiki page

AWS environment:

The AWS environment supports both continuous integration and continuous deployment. The environment is made of the following components:

  • Github repository (nditech/CyberSim-Backend): Each change on the local repositories are pushed to a new branch in the Github remote. Once these changes are reviewed, they are merged into the master branch.

  • CodePipeline (ndi-cybersim-backend-staging, ndi-cybersim-backend-prod): A CodePipeline project is created for both staging and production environments. For the staging environment a webhook is registered on Github, so each change on the master branch will trigger and automatic build on AWS. For the production environment no webhook is registered so changes on the master branch will require a manual release in CodePipeline.

  • CodeBuild (ndi-cybersim-backend): A single CodeBuild project is created to build and test both staging and production changes. After a change is triggered on CodePiepeline (manually or automatically), the source code is transferred to CodeBuild and the steps defined in the buildspec.yml file are executed. These steps include the installation of node, npm packages and Postgres on a virtual machine and the execution of predefined database related tests. Once these tests are run, CodePiepeline begins the deployment.

  • Elastic Beanstalk (NdiCybersimBackend-staging, NdiCybersimBackend-prod): In Elastic Beanstalk (EB) a different environment is created for both staging and production. In both environments, the node application is running inside a docker container so an existing Dockerfile inside the source code is necessary for EB. The docker image is created using the Dockerfile in the root. Once the deployment is compleated, the API will be live. For EB the following environment variables must be set (These variables can be set seberatly for each EB environment under the Configuration/Software Tab of the AWS Console.):

    • PORT: The PORT must match the port exposed in the docker container which currently is 3001.
    • NODE_ENV: Must be either production, development or test. If the given value is test the server will reset the Postgres Database on each restart.
    • DB_URL: The connection string for the Postgres Database which is the following: postgres://:@:/<DB_NAME>
  • RDS (aa1p6s0h1so0mf9): A Postgres Database is created to store the data for both staging and production environments The default name of the RDS database is ebdb. This DB is only available for the EC2 instance running inside the EB environment. In order to connect to the DB from a different client, port forwarding must be configured. In order to create an ssh tunnel and forward the traffic from the DB to locahost run to following commands:

# Create the tunnel using ssh. Please note that you need the private key for this command.
$ ssh -N  -L 5432:aa1p6s0h1so0mf9.cp0uibxnlhse.us-east-2.rds.amazonaws.com:5432 [email protected] -i <PRIVATE_KEY>
# Connect to the DB on localhost:5432
$ psql -U cybersim --password -h 127.0.0.1 -p 5432

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.