Skip to content

Commit

Permalink
Add Babel presets, update Docker settings, install tools, configure E…
Browse files Browse the repository at this point in the history
…SLint rules, and set up CI workflows.

Add Babel presets, update Docker settings, install tools, configure ESLint rules, and set up CI workflows.

Added Babel presets for React and TypeScript in .babelrc. Updated Docker settings in devcontainer.json. Installed tools and configured ESLint rules in .eslintrc.yml. Set up CI workflows for security checks in ci.yml.
  • Loading branch information
XOwlPost committed Mar 13, 2024
1 parent b21c11c commit f32fdd1
Show file tree
Hide file tree
Showing 69 changed files with 14,795 additions and 1,049 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"]
}

92 changes: 85 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,104 @@

# Use Miniconda base image
FROM continuumio/miniconda3

# Install Node.js and npm via Conda
RUN conda install -c conda-forge nodejs
# Install Node.js version 20.9.0 (correcting the command)
RUN conda install -c conda-forge nodejs=20.9.0

# Install Yarn (using npm, which comes with Node.js)
RUN npm install -g yarn

# Copy the environment.yml file into the container to define your Conda environment
# Copy both the environment.yml for Conda and package.json (and yarn.lock if available) for Yarn
COPY environment.yml /tmp/environment.yml
COPY package.json yarn.lock* /tmp/

# Use the environment.yml to create the Conda environment
RUN conda env create -f /tmp/environment.yml

# Make RUN commands use the new environment
SHELL ["conda", "run", "-n", "pre-commit-env", "/bin/bash", "-c"]

RUN pip install checkov terrascan

SHELL ["docker run --rm -i hadolint/hadolint < Dockerfile"]

SHELL ["docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/Library/Caches:/root/.cache/ aquasec/trivy image [my-frontend-app] " ]

# Install JavaScript dependencies with Yarn
RUN cd /tmp && yarn install

# Copy the installed JavaScript dependencies (and other necessary files) into the working directory
COPY . /app
WORKDIR /app

# The code below ensures that the environment is activated on startup
RUN echo "conda activate pre-commit-env" >> ~/.bashrc

# Install JupyterLab in the Conda environment
# (Optional) Install JupyterLab in the Conda environment if you need it
RUN conda run -n pre-commit-env pip install jupyterlab

# Set the default command to run when starting the container. Here, we start JupyterLab.
CMD ["conda", "run", "-n", "pre-commit-env", "jupyter", "lab", "--ip='*'", "--port=8888", "--no-browser", "--allow-root"]
# Set the default command for the container. Adjust as needed.
CMD ["conda", "run", "-n", "pre-commit-env", "your-command-here"]

name: Lint and Build

on:
push:
branches:
- main
- feature/**
pull_request:

jobs:
lint-dockerfiles:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# Lint Dockerfile in root directory
- name: Lint Root Dockerfile
uses: hadolint/hadolint-action@v1.5.0
with:
dockerfile: ./Dockerfile

# Lint Dockerfile in .devcontainer directory
- name: Lint Devcontainer Dockerfile
uses: hadolint/hadolint-action@v1.5.0
with:
dockerfile: ./.devcontainer/Dockerfile

build:
needs: lint-dockerfiles
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build Docker Image from Root
run: |
docker build -t my-app:latest .

- name: Build Docker Image from .devcontainer
run: |
docker build -f ./.devcontainer/Dockerfile -t my-devcontainer:latest .

# Use Miniconda base image
FROM continuumio/miniconda3

# Install dependencies, etc.

# Copy your application's source code and the entrypoint script
COPY . /app
COPY entrypoint.sh /usr/local/bin/entrypoint.sh

# Set the working directory
WORKDIR /app

# Make the entrypoint script executable
RUN chmod +x /usr/local/bin/entrypoint.sh

# Set the entrypoint to run your script
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]


# Expose the port JupyterLab runs on
# Expose any ports your application uses (e.g., for a web server)
EXPOSE 8888
69 changes: 34 additions & 35 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
{
"name": "21XO-MVP",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "11",
"INSTALL_NODE": "true"
}
},
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"postCreateCommand": "npm install",
"remoteUser": "vscode",
"extensions": [
"dbaeumer.vscode-eslint",
"GitHub.codespaces",
"ms-azuretools.vscode-docker",
"cweijan.vscode-postgresql-client2",
"tintinweb.solidity-visual-auditor",
"github.vscode-github-actions",
"AvneeshAgarwal.thirdweb-snippets",
"GitHub.copilot",
"streetsidesoftware.code-spell-checker",
"VisualStudioExptTeam.vscodeintellicode",
"ms-python.python",
"bmewburn.vscode-intelephense-client",
"NomicFoundation.hardhat-solidity",
"redhat.vscode-yaml",
"ms-dotnettools.vscode-dotnet-runtime",
"eamodio.gitlens"
],
"forwardPorts": [3000]
}
{
"name": "21XO-MVP",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"settings": {
"terminal.integrated.defaultProfile.linux": "bash"
},
"postCreateCommand": "echo 'Remember to manually create and activate the Conda environment, then install JupyterLab and npm packages'",
"remoteUser": "vscode",
"extensions": [
"dbaeumer.vscode-eslint",
"GitHub.codespaces",
"ms-azuretools.vscode-docker",
"cweijan.vscode-postgresql-client2",
"tintinweb.solidity-visual-auditor",
"github.vscode-github-actions",
"AvneeshAgarwal.thirdweb-snippets",
"GitHub.copilot",
"streetsidesoftware.code-spell-checker",
"VisualStudioExptTeam.vscodeintellicode",
"ms-python.python",
"bmewburn.vscode-intelephense-client",
"NomicFoundation.hardhat-solidity",
"redhat.vscode-yaml",
"ms-dotnettools.vscode-dotnet-runtime",
"eamodio.gitlens",
"ms-vscode-remote.remote-containers",
"ms-vscode-remote.remote-wsl"
],
"forwardPorts": [3000, 8888]
}

72 changes: 36 additions & 36 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# EditorConfig is awesome: https://EditorConfig.org

# Top-level EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

# Matches multiple files with brace expansion notation
# Set indent style and size for JavaScript, JSON, HTML, CSS, and similar files
[*.{js,json,html,css,scss,md}]
indent_style = space
indent_size = 2

# Override for Python files
[*.py]
indent_style = space
indent_size = 4

# Override for Java files
[*.java]
indent_style = space
indent_size = 4

# Override for C++ files
[*.{cpp,h}]
indent_style = space
indent_size = 4

# Markdown files (Markdownlint often prefers no trailing whitespace)
[*.md]
trim_trailing_whitespace = false
# EditorConfig is awesome: https://EditorConfig.org

# Top-level EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

# Matches multiple files with brace expansion notation
# Set indent style and size for JavaScript, JSON, HTML, CSS, and similar files
[*.{js,json,html,css,scss,md}]
indent_style = space
indent_size = 2

# Override for Python files
[*.py]
indent_style = space
indent_size = 4

# Override for Java files
[*.java]
indent_style = space
indent_size = 4

# Override for C++ files
[*.{cpp,h}]
indent_style = space
indent_size = 4

# Markdown files (Markdownlint often prefers no trailing whitespace)
[*.md]
trim_trailing_whitespace = false
34 changes: 34 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
env:
browser: true
es2021: true
node: true
extends:
- eslint:recommended
- plugin:@typescript-eslint/recommended
- plugin:react/recommended
- plugin:react-hooks/recommended
- airbnb
- airbnb/hooks
- airbnb-typescript
parser: '@typescript-eslint/parser'
parserOptions:
ecmaFeatures:
jsx: true
ecmaVersion: 12 # Equivalent to 2021
sourceType: 'module'
project: './config/tsconfig.json' # Specify the path to your tsconfig if you're using TypeScript
plugins:
- '@typescript-eslint'
- react
- react-hooks
rules:
indent: ['error', 2]
quotes: ['error', 'single']
semi: ['error', 'always']
"@typescript-eslint/no-unused-vars": ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }]
"react/jsx-filename-extension": [1, { "extensions": [".tsx", ".jsx"] }]
"react/jsx-uses-react": "off"
"react/react-in-jsx-scope": "off"
"react-hooks/rules-of-hooks": 'error' # Checks rules of Hooks
"react-hooks/exhaustive-deps": 'warn' # Checks effect dependencies

26 changes: 13 additions & 13 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [XOwlPost]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['21XO.eth']
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [XOwlPost]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['21XO.eth']
Loading

0 comments on commit f32fdd1

Please sign in to comment.