Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
Co-authored-by: Jayson Grace <[email protected]>
Co-authored-by: Samuel Manzer <[email protected]>
Co-authored-by: Alek Straumann <[email protected]>
  • Loading branch information
4 people committed Aug 10, 2023
0 parents commit 5d4f093
Show file tree
Hide file tree
Showing 106 changed files with 11,760 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .asdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
### Examples: ###
# Employ asdf for go, ruby, and python used by this project only:
# source .asdf
# Employ asdf for python used by this project only:
# source .asdf python

# Define the URL of setup_asdf.sh
setup_asdf_url="https://raw.githubusercontent.com/l50/dotfiles/main/files/setup_asdf.sh"

# Define the local path of setup_asdf.sh
setup_asdf_path="/tmp/setup_asdf.sh"

# Check if setup_asdf.sh exists locally
if [[ ! -f "${setup_asdf_path}" ]]; then
# setup_asdf.sh doesn't exist locally, so download it
curl -s "${setup_asdf_url}" -o "${setup_asdf_path}"
fi

# Source /tmp/setup_asdf.sh
# shellcheck source=/dev/null
source "${setup_asdf_path}"

# Function to setup language
setup_language_if_requested() {
local language="$1"

# Check if the language is requested or if no language is specified
if [[ " $* " =~ " $language " ]] || [[ $# -eq 0 ]]; then
# Setup the language
setup_language "$language" "local"
fi
}

# Call setup_language_if_requested for each language
setup_language_if_requested "$@" "golang"
setup_language_if_requested "$@" "python"
setup_language_if_requested "$@" "ruby"
58 changes: 58 additions & 0 deletions .devcontainer/bash/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM golang:1.20.7

# Set build-time arguments for user and group IDs
ARG USER_ID=1000
ARG GROUP_ID=1000

# Install necessary dependencies
RUN DEBIAN_FRONTEND="noninteractive" apt-get update \
&& apt-get install -y bison curl git python3 python3-pip ruby-full shellcheck unzip vim

# Install GitHub CLI
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt-get update \
&& apt-get install -y gh

# Install Terragrunt
RUN TERRAGRUNT_VERSION="0.45.2" \
&& curl -sL https://github.com/gruntwork-io/terragrunt/releases/download/v${TERRAGRUNT_VERSION}/terragrunt_linux_amd64 -o /tmp/terragrunt \
&& install -o root -g root -m 0755 /tmp/terragrunt /usr/local/bin/terragrunt \
&& rm /tmp/terragrunt

# Create the ttpforge user and change ownership of the necessary directories
RUN useradd -m -s /bin/bash ttpforge \
&& mkdir -p /home/ttpforge/go/src/github.com/facebookincubator/TTPForge \
&& chown -R ttpforge:ttpforge /home/ttpforge/go

COPY --chown=ttpforge . /home/ttpforge/go/src/github.com/facebookincubator/ttpforge

# Set the 'ttpforge' user as the default user
USER ttpforge
ENV GOPATH=/home/ttpforge/go
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin:/home/ttpforge/.local/bin
WORKDIR /home/ttpforge/go/src/github.com/facebookincubator/ttpforge

# Install pre-commit
RUN python3 -m pip install --upgrade pip \
&& python3 -m pip install --upgrade pre-commit \
&& pre-commit install

# Install go dependencies
RUN /bin/bash -c " \
go install github.com/magefile/mage@latest \
&& go install mvdan.cc/sh/v3/cmd/shfmt@latest \
# Install project dependencies
&& mage installDeps \
&& mage \
# Run go mod tidy and build the project
# to speed up builds
&& go mod tidy \
&& go build -o ttpforge \
# Clean up the compiled bin
&& rm ttpforge"

# Remove the copied repository content
RUN rm -rf /home/ttpforge/go/src/github.com/facebookincubator/ttpforge

CMD ["bash"]
15 changes: 15 additions & 0 deletions .devcontainer/bash/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "TTPForge Bash Container",
"image": "ghcr.io/facebookincubator/ttpforge-bash:latest",
"remoteUser": "ttpforge",
"extensions": [
// Go Extension
"golang.go",
// Python Extension
"ms-python.python",
// Bash IDE Extension
"mads-hartmann.bash-ide-vscode",
// YAML Extension
"redhat.vscode-yaml"
]
}
95 changes: 95 additions & 0 deletions .devcontainer/zsh/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
FROM ghcr.io/facebookincubator/pt-ubuntu-vnc-zsh:latest

# Set build-time arguments for user and group IDs
ARG USER_ID=1000
ARG GROUP_ID=1000

# Add the ubuntu user to sudoers
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' | sudo tee -a /etc/sudoers

# Install necessary dependencies
RUN DEBIAN_FRONTEND="noninteractive" sudo apt-get update \
&& sudo apt-get install -y bison curl expect git python3 python3-pip ruby-full shellcheck unzip vim

# Install GitHub CLI
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt-get update \
&& sudo apt-get install -y gh

# Install Terragrunt
RUN TERRAGRUNT_VERSION="0.45.2" \
&& curl -sL https://github.com/gruntwork-io/terragrunt/releases/download/v${TERRAGRUNT_VERSION}/terragrunt_linux_amd64 -o /tmp/terragrunt \
&& sudo install -o root -g root -m 0755 /tmp/terragrunt /usr/local/bin/terragrunt \
&& sudo rm /tmp/terragrunt

# Switch to root user
USER root

# Change the ubuntu user to the ttpforge user
RUN groupmod -n ttpforge ubuntu \
&& usermod -l ttpforge -g ttpforge ubuntu \
&& usermod -d /home/ttpforge -m ttpforge \
&& mkdir -p /home/ttpforge/go/src/github.com/csdXrStkMjREnjZGU/ttpforge \
&& chown -R ttpforge:ttpforge /home/ttpforge/go \
&& usermod -a -G sudo ttpforge

# Create the VNC password and configuration for the ttpforge user
RUN mkdir -p /home/ttpforge/.vnc \
&& chown ttpforge:ttpforge /home/ttpforge/.vnc \
&& chmod 0700 /home/ttpforge/.vnc \
&& su ttpforge -c "touch /home/ttpforge/.vnc/passwd" \
&& su ttpforge -c "chmod 0600 /home/ttpforge/.vnc/passwd"

# Update the VNC password for ttpforge user
RUN su ttpforge -c "echo 'ttpforge' | vncpasswd -f > /home/ttpforge/.vnc/passwd"

# Create the new docker-entrypoint.sh script with the correct username and home directory
RUN echo '#!/usr/bin/env zsh\n\
# docker-entrypoint.sh for docker image creation.\n\
set -x\n\
\n\
. /home/ttpforge/.zshrc\n\
start_vnc\n\
\n\
exec "$@"' > /run/docker-entrypoint.sh \
&& chmod +x /run/docker-entrypoint.sh

COPY --chown=ttpforge .. /home/ttpforge/go/src/github.com/facebookincubator/ttpforge

# Set the 'ttpforge' user as the default user
USER ttpforge
ENV GOPATH=/home/ttpforge/go
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin:/home/ttpforge/.local/bin
WORKDIR /home/ttpforge/go/src/github.com/facebookincubator/ttpforge

# Install pre-commit
RUN python3 -m pip install --upgrade pip \
&& python3 -m pip install --upgrade pre-commit \
&& pre-commit install

# Install asdf
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf

# Install Go using asdf
RUN /usr/bin/zsh -c "source .asdf \
# Install go dependencies
&& go install github.com/magefile/mage@latest \
&& go install mvdan.cc/sh/v3/cmd/shfmt@latest \
# Install project dependencies
&& mage installDeps \
&& mage \
# Run go mod tidy and build the project
# to speed up builds
&& go mod tidy \
&& go build -o ttpforge \
# Clean up the compiled bin
&& rm ttpforge"

# Remove the copied repository content
RUN rm -rf /home/ttpforge/go/src/github.com/facebookincubator/ttpforge

# Add the asdf source to the .zshrc file
RUN echo "\nsource /home/ttpforge/go/src/github.com/facebookincubator/ttpforge/.asdf" | tee -a /home/ttpforge/.zshrc

CMD ["zsh"]
15 changes: 15 additions & 0 deletions .devcontainer/zsh/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "TTPForge ZSH Container",
"image": "ghcr.io/facebookincubator/ttpforge-zsh:latest",
"remoteUser": "ttpforge",
"extensions": [
// Go Extension
"golang.go",
// Python Extension
"ms-python.python",
// Bash IDE Extension
"mads-hartmann.bash-ide-vscode",
// YAML Extension
"redhat.vscode-yaml"
]
}
1 change: 1 addition & 0 deletions .docgenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ttps
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[*.sh]
# like -i=4
indent_style = space
indent_size = 4

binary_next_line = true # like -bn
switch_case_indent = true # like -ci
space_redirects = true # like -sr
keep_padding = true # like -kp
function_next_line = true # like -fn
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
* @l50 @CrimsonK1ng @d3sch41n
80 changes: 80 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

This Code of Conduct also applies outside the project spaces when there is a
reasonable belief that an individual's behavior may have a negative impact on
the project or its community.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at <[email protected]>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
<https://www.contributor-covenant.org/faq>
36 changes: 36 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Contributing to TTPForge

We want to make contributing to this project as easy and transparent as
possible.

## Pull Requests

We actively welcome your pull requests.

1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.
6. If you haven't already, complete the Contributor License Agreement ("CLA").

## Contributor License Agreement ("CLA")

In order to accept your pull request, we need you to submit a CLA. You only need
to do this once to work on any of Facebook's open source projects.

Complete your CLA here: <https://code.facebook.com/cla>

## Issues

We use GitHub issues to track public bugs. Please ensure your description is
clear and has sufficient instructions to be able to reproduce the issue.

Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue.

## License

By contributing to TTPForge, you agree that your contributions will be licensed
under the LICENSE file in the root directory of this source tree.
Loading

0 comments on commit 5d4f093

Please sign in to comment.