Skip to content

Commit

Permalink
Merge pull request #84 from oslabs-beta/dev
Browse files Browse the repository at this point in the history
Version 0.1.0
  • Loading branch information
nanyi-deng authored Oct 31, 2024
2 parents 2b47ede + 81bbfbb commit 2582e28
Show file tree
Hide file tree
Showing 58 changed files with 12,132 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
# **/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md
47 changes: 47 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# .github/workflows/lint-format.yml

name: Lint and Format

# Run this workflow on pull requests targeting 'main' or 'dev' branches
on:
pull_request:
branches:
- main
- dev

jobs:
lint-and-format:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the code
- name: Checkout code
uses: actions/checkout@v4

# Step 2: Set up Node.js (specify the Node version if required)
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # Adjust the version if necessary

# Step 3: Install dependencies
- name: Install dependencies
run: npm install

# Step 4: Run ESLint to check for linting issues
- name: Run ESLint
run: npm run lint -- --fix # Make sure you have a lint script in package.json

- name: List Changes
run: git status --porcelain

# Step 6: Check for changes after formatting
- name: Check for formatting changes
run: |
if [[ `git status --porcelain` ]]; then
echo "There are formatting changes."
echo "Please commit the changes locally or configure auto-formatting in Prettier."
exit 1
else
echo "No formatting changes needed."
fi
25 changes: 24 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_STORE
dist
dist-ssr
*.local
*.tsbuildinfo
.env

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "es5"
}
72 changes: 72 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# syntax=docker/dockerfile:1
ARG NODE_VERSION=20.16.0

################################################################################
# Use node image for base image for all stages.
FROM node:${NODE_VERSION}-alpine AS base

# Set working directory for all build stages.
WORKDIR /usr/src/app


################################################################################
# Create a stage for installing production dependecies.
FROM base AS deps

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
# Leverage bind mounts to package.json and package-lock.json to avoid having to copy them
# into this layer.
RUN --mount=type=bind,source=package.json,target=package.json \
# workaround for npm optional dependencies bug: https://github.com/npm/cli/issues/4828
# --mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm i --omit=dev

################################################################################
# Create a stage for building the application.
FROM deps AS dev-deps


# Download additional development dependencies before building, as some projects require
# "devDependencies" to be installed to build. If you don't need this, remove this step.
RUN --mount=type=bind,source=package.json,target=package.json \
# workaround for npm optional dependencies bug: https://github.com/npm/cli/issues/4828
# --mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm i

FROM dev-deps AS build
# Copy the rest of the source files into the image.
COPY . .
# Run the build script.
RUN npx tsc -b
RUN npx vite build

################################################################################
# Create a new stage to run the application with minimal runtime dependencies
# where the necessary files are copied from the build stage.
FROM base AS final

# Use production node environment by default.
ENV NODE_ENV=production

# Run the application as a non-root user.
USER node

# Copy package.json so that package manager commands can be used.
COPY package.json .

# Copy the production dependencies from the deps stage and also
# the built application from the build stage into the image.
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/server ./
COPY --from=build /usr/src/app/dist ./dist



# Expose the port that the application listens on.
EXPOSE 8080

# Run the application.
CMD [ "node", "server.js" ]
2 changes: 2 additions & 0 deletions Dockerfile-postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM postgres:12.8
COPY ./scripts/db_init.sql /docker-entrypoint-initdb.d/
22 changes: 22 additions & 0 deletions README.Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Building and running your application

When you're ready, start your application by running:
`docker compose up --build`.

Your application will be available at http://localhost:8080.

### Deploying your application to the cloud

First, build your image, e.g.: `docker build -t myapp .`.
If your cloud uses a different CPU architecture than your development
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
you'll want to build the image for that platform, e.g.:
`docker build --platform=linux/amd64 -t myapp .`.

Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.

Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
docs for more detail on building and pushing.

### References
* [Docker's Node.js guide](https://docs.docker.com/language/nodejs/)
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
# TrailGuide
# TrailGuide

[TrailGuide](https://oslabs-beta.github.io/TrailGuideIO/) is a open source AWS cloud security solution for developers who need their cloud security reassured.

We built TrailGuide because we are passionate in solving the data overloading problem in the cloud. Join us!

- Track key management events: Quickly view events related to creating, modifying, or deleting AWS resources.
- Visualize CloudTrail data: Present data in easy-to-read formats, such as pie charts for event distribution and heatmaps for geographical IP access.
- Analyze recent events based on various criteria, such as IP addresses, event types, associated users, and timestamps.

Every single part is fully open source! Fork it, extend it, or deploy it to your own server.

<img src="./readmeAssets//trailguide-readme-main.webp" alt="List View Screenshot" width="500">

# Installation and Spin-Up

- Make sure you have docker installed
- Create your compose.yml file
- (see our starter version in [Docker Hub](https://hub.docker.com/r/trailguide/trailguide-prod), or copy the one from this repo )
- run `docker compose up` on the command line

# Getting Start:

1. Use the signup link to create user

<img src="./readmeAssets/sign-up.png" alt="List View Screenshot" width="500">

2. Login

<img src="./readmeAssets/log-in.png" alt="List View Screenshot" width="500">

3. Copy paste the aws credentials in the fields in the profile

<img src="./readmeAssets/aws-credential.png" alt="List View Screenshot" width="500">

## Shoutouts :tada:

Omnivore takes advantage of some great open source software:

- [TypeScript](https://www.typescriptlang.org/) - Most of our backend and frontend are written in TypeScript.
- [PostgreSQL](https://www.postgresql.org/)- For managing complex queries and storing event data, PostgreSQL is our go-to. Its reliability and performance are key to managing and analyzing extensive data, enhancing the robustness of our monitoring and analytics features.
- [Docker](https://www.docker.com/)- Thanks to Docker, deploying our platform is seamless and consistent, whether locally or on the cloud. Docker allows us to containerize our ML models and backend services, ensuring reliable and scalable performance for our users.
- [AWS](https://aws.amazon.com/)- AWS forms the backbone of TrailGuide, providing the infrastructure and data streams that allow us to offer real-time monitoring and security insights for AWS environments. CloudTrail logs enable us to dive deep into user activity and detect anomalies as they happen.
- [Scikit-learn](https://scikit-learn.org/)- TrailGuide’s anomaly detection thrives with Scikit-learn's Isolation Forest, enabling real-time detection of unusual activity in CloudTrail logs with efficiency and accuracy.
- And many more awesome libraries, just checkout our package files to see what we are using.

## Requirements for development

TraildeGuide is written in TypeScript and JavaScript.
17 changes: 17 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="A brief description of your application." />
<link href="https://fonts.googleapis.com/css2?family=Fredoka&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c&display=swap" rel="stylesheet">
<link rel="icon" href="path/to/favicon.ico" />
<title>TrailGuide</title>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
</head>
<body>
<div id="root"></div>
<script type="module" src="src/main.tsx" defer></script>
</body>
</html>
Loading

0 comments on commit 2582e28

Please sign in to comment.