Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add waypoint for dev environment creation #197

Draft
wants to merge 106 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
223593f
:tada: Add initial Waypoint structure
joyliu-q Feb 5, 2025
0b09140
NVM install fix
ryantanen Feb 6, 2025
a56582a
:art: Temp changes
joyliu-q Feb 6, 2025
406a82a
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 6, 2025
781d6a6
redis, yarn, and fixes
ryantanen Feb 7, 2025
fa0b66d
:tada: Add waypoint client
joyliu-q Feb 7, 2025
c0fb9d9
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 7, 2025
a49c568
Add waypoint bootstrap setup (postgres, redis, cli)
ryantanen Feb 7, 2025
b938f73
Re-added waypoint init which initalizes backend
ryantanen Feb 7, 2025
0bd0e89
Updated bashrc to include nvm
ryantanen Feb 7, 2025
36c86b2
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 7, 2025
2bf7741
tmp: Added node versions and frontend/backend start
ryantanen Feb 8, 2025
cb8de4b
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 8, 2025
3026129
:art: Add waypoint client release
joyliu-q Feb 8, 2025
b1423c7
:art: Add waypoint client release
joyliu-q Feb 8, 2025
59573ec
:fire: remove waypoint brew component
joyliu-q Feb 8, 2025
1c68b30
:art: waypoint install temp workaround
joyliu-q Feb 8, 2025
feb6c4d
:fire: Added VSCode auto open and set node to 20 always. Moved yarn i…
ryantanen Feb 8, 2025
433fde9
:bug: Temp workarond to trigger workflow
joyliu-q Feb 8, 2025
50bbe27
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 8, 2025
702af4a
:art: add random echo
joyliu-q Feb 8, 2025
36bbc1d
update gitignore
ryantanen Feb 9, 2025
cdec5c2
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 9, 2025
5e618f9
:bug: Fix some path related bugs
joyliu-q Feb 9, 2025
0770183
:bug: Fix some path related bugs
joyliu-q Feb 9, 2025
91ded17
:art: Arbitrary new line
joyliu-q Feb 9, 2025
10dedd7
:art: Arbitrary change
joyliu-q Feb 9, 2025
59798fb
:art: HUHH iT WORKED??
joyliu-q Feb 9, 2025
64f9910
:bug: Cringe
joyliu-q Feb 9, 2025
395c709
:bug: fix waypoint install script
joyliu-q Feb 9, 2025
dec8377
:art: goofing out
joyliu-q Feb 9, 2025
802816c
:art: goofing out
joyliu-q Feb 9, 2025
63dfc91
:bug: Clone repos at runtime, add init-all function, better exit hand…
joyliu-q Feb 9, 2025
7c9d7dd
:arrow_up: Bump version
joyliu-q Feb 9, 2025
4b0b680
:construction_worker: Add common debug tools
joyliu-q Feb 9, 2025
0e0c491
:bug: Check for errors on manage.py
ryantanen Feb 9, 2025
782eb92
:tada: Add config directory for ssh and gpg keys
joyliu-q Feb 9, 2025
6ddded7
:tada: Add env syncing and client changes
joyliu-q Feb 9, 2025
c07905e
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 9, 2025
26ced80
Added python linter
ryantanen Feb 9, 2025
2a94df2
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 9, 2025
1a9beca
:bug: Fixed waypoint init all products
ryantanen Feb 9, 2025
1841461
:tada: Different arch
joyliu-q Feb 9, 2025
3df4afe
Add docker action
Clue88 Feb 9, 2025
f03b17d
Merge branch 'add-waypoint' of github.com:pennlabs/infrastructure int…
Clue88 Feb 9, 2025
06c03d7
ahh
ryantanen Feb 9, 2025
55b4abc
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 9, 2025
5db4e99
ahh2
ryantanen Feb 9, 2025
d35c683
Push to docker always
Clue88 Feb 9, 2025
2d0f33e
yay
Clue88 Feb 9, 2025
41a22b2
:arrow_up: Bump install
joyliu-q Feb 9, 2025
d60093f
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 9, 2025
efbb0e2
:arrow_up: Fix
joyliu-q Feb 9, 2025
18c5436
:arrow_up: bump install
joyliu-q Feb 9, 2025
42e90b0
Multi platform
Clue88 Feb 9, 2025
0fd26c5
trigger docker build
Clue88 Feb 9, 2025
03b867f
Update Readme
ryantanen Feb 9, 2025
43b1136
tmp: Create install-waypoint.sh
ryantanen Feb 9, 2025
fcfbbf4
Update install-waypoint.sh
ryantanen Feb 9, 2025
a8329d5
Update install-waypoint.sh
ryantanen Feb 9, 2025
09a3099
:art: Fix
joyliu-q Feb 13, 2025
1d00697
Added penn-mobile diff
ryantanen Feb 13, 2025
0f28eee
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
ryantanen Feb 13, 2025
f5e815b
:bug: Fix multiplatform by bumping versions
joyliu-q Feb 13, 2025
cde0c81
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
joyliu-q Feb 13, 2025
e8e5ea3
:bug: Add systemd installs
joyliu-q Feb 13, 2025
87919ef
:bug: Remove gh install
joyliu-q Feb 13, 2025
5d2c034
Added ToDo
ryantanen Feb 13, 2025
0248cf7
:bug: not rlly Fix waypoint image not found in cicd
joyliu-q Feb 13, 2025
758d15a
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
ryantanen Feb 13, 2025
6c3a700
:bug: not rlly Fix waypoint image not found in cicd
joyliu-q Feb 13, 2025
a892bef
:arrow_down: Bump down ubuntu 20
joyliu-q Feb 13, 2025
e717697
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
ryantanen Feb 13, 2025
3e9ba0f
:arrow_down: Bump down ubuntu 20
joyliu-q Feb 13, 2025
a73a9bb
:arrow_down: Bump down ubuntu 20
joyliu-q Feb 13, 2025
0207769
:arrow_up: Build two macos builds and 1 linux build
joyliu-q Feb 13, 2025
aed5328
:bug: Fix path bug OMG BRUH joy
joyliu-q Feb 13, 2025
21c1d95
:art: Malding
joyliu-q Feb 13, 2025
7fe8d9e
:bug: I dont trust
joyliu-q Feb 13, 2025
d238850
:art: huh
joyliu-q Feb 13, 2025
4da5e3a
:bug: fix?
joyliu-q Feb 13, 2025
597d45d
:art: Fix docker image
joyliu-q Feb 13, 2025
9e4a757
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
ryantanen Feb 14, 2025
4b1cb03
Fixes for Penn-Courses
ryantanen Feb 16, 2025
c23d331
Update version
ryantanen Feb 16, 2025
b829512
Update workflow
ryantanen Feb 16, 2025
1d06459
Fix Workflow
ryantanen Feb 16, 2025
ab6971e
fix
ryantanen Feb 16, 2025
7928249
Bump install.sh
ryantanen Feb 16, 2025
f4632b8
Penn Courses Fix
ryantanen Feb 16, 2025
76b0e1a
Bump
ryantanen Feb 16, 2025
0ca831c
Small Fix to penn-courses
ryantanen Feb 16, 2025
b8fd4d2
Add Penn Courses SQL populate
ryantanen Feb 21, 2025
fc13773
Bump
ryantanen Feb 21, 2025
5eec3f3
QOL and Platform
ryantanen Feb 24, 2025
04faa4a
Clean Up and Created Utils
ryantanen Mar 6, 2025
ca46e98
Added waypoint-client spawn to make it easy to exec into waypoint fro…
ryantanen Mar 6, 2025
54c3e1f
Update Workflow for Docker Release
ryantanen Mar 7, 2025
30dd71a
Update Workflow for Docker Release
ryantanen Mar 7, 2025
33b0555
Update install.sh
ryantanen Mar 9, 2025
cae4ef8
:bug: Fixed a bug that would cause multiple containers to be made, ad…
ryantanen Mar 9, 2025
10169fc
:bug: Fixed a bug that would cause multiple containers to be made, ad…
ryantanen Mar 9, 2025
9ef6c89
:bug: Fixed a bug that would cause multiple containers to be made, ad…
ryantanen Mar 9, 2025
fa580f0
:bug: Silence docker start
ryantanen Mar 9, 2025
cdddd25
:bug: Interactive shell fix
ryantanen Mar 9, 2025
a01810c
Bump Version
ryantanen Mar 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/cdkactions_docker-waypoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish waypoint
on:
push:
paths:
- docker/waypoint/**

jobs:
publish-waypoint:
name: Publish waypoint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
image: tonistiigi/binfmt:latest
- uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-publish-waypoint
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build/Publish
uses: docker/build-push-action@v6
with:
context: docker/waypoint
file: docker/waypoint/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/waypoint:latest
cache-to: type=local,dest=/tmp/.buildx-cache
tags: |
pennlabs/waypoint:latest
pennlabs/waypoint:${{ github.sha }}
54 changes: 54 additions & 0 deletions .github/workflows/release-waypoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
arch: x86_64
binary_suffix: "-linux-x86_64"
- os: macos-latest
arch: x86_64
binary_suffix: "-macos-x86_64"
- os: macos-latest
arch: arm64
binary_suffix: "-macos-arm64"

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install dependencies
run: |
pip install pyinstaller
cd docker/waypoint && pip install .

- name: Build binary
working-directory: docker/waypoint
run: pyinstaller src/waypoint_client.py --onefile --name "waypoint-client${{ matrix.binary_suffix }}"

- name: Calculate SHA256
run: |
cd docker/waypoint/dist
echo "BINARY_SHA=$(sha256sum waypoint-client${{ matrix.binary_suffix }} | awk '{print $1}')" >> $GITHUB_ENV

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: docker/waypoint/dist/waypoint-client*
name: Release ${{ github.ref_name }}
body: |
SHA256 (${{ matrix.os }}-${{ matrix.arch }}): ${{ env.BINARY_SHA }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ creds.txt
terraform.*
tf_creds.json
.DS_Store
*.log

__pycache__
waypoint.egg-info
67 changes: 67 additions & 0 deletions docker/waypoint/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM ubuntu:20.04

LABEL maintainer="Penn Labs"


# --- systems setup
RUN apt-get update && apt-get install --no-install-recommends -y gcc libpq-dev libc-dev

RUN apt-get update && apt-get install --no-install-recommends -y curl git \
sudo python3-dev python3-pip python3-venv libpq-dev postgresql-client nano \
htop vim net-tools procps sysstat strace tcpdump lsof \
&& rm -rf /var/lib/apt/lists/*

# Install locales and configure the correct locale
# RUN apt-get update && apt-get install -y locales
# RUN locale-gen en_US.UTF-8
# RUN update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8

RUN pip3 install uv pipenv

# --- labs setup
# TODO: install and set up postgres db w systemd
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y tzdata \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reasonably certain there might be a nicer way to do this same line but will have to see.

Also, if the timezone bug hasn't been resolved yet, would prefer to remove partial patch.

&& ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata

RUN apt-get update && apt-get install -y postgresql postgresql-contrib redis-server systemd

# Install nvm, node, and npm, yarn
ENV NVM_DIR=/usr/local/nvm
ENV NODE_VERSION=20

RUN mkdir -p $NVM_DIR && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash && \
. $NVM_DIR/nvm.sh && \
nvm install $NODE_VERSION && \
nvm alias default $NODE_VERSION && \
nvm use default

RUN . $NVM_DIR/nvm.sh && npm install -g yarn

RUN mkdir /opt/waypoint/
RUN mkdir /labs/

# For each product, setup the python environment
COPY waypoint-init /opt/waypoint/waypoint-init
RUN chmod +x /opt/waypoint/waypoint-init
RUN /opt/waypoint/waypoint-init

# start redis and postgres service
COPY database-init /opt/waypoint/database-init
RUN chmod +x /opt/waypoint/database-init

RUN mkdir -p /opt/waypoint/cli
COPY . /opt/waypoint/cli
WORKDIR /opt/waypoint/cli
RUN pip3 install .

WORKDIR /

# Copy .bashrc
COPY waypoint-bashrc /root/.bashrc

# expose ports
EXPOSE 5432
EXPOSE 3000
EXPOSE 8000
116 changes: 116 additions & 0 deletions docker/waypoint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Waypoint

A development environment manager for Penn Labs products.

## Installation

### Set-up

To get started, install `waypoint-client` on your local machine by running:

```bash
curl -sSL https://raw.githubusercontent.com/pennlabs/infrastructure/refs/heads/add-waypoint/docker/waypoint/install.sh | sudo bash
```

Next, configure `waypoint-client`:

```bash
waypoint-client configure
```

This setup ensures your code, secrets, and config files persist even if the container is rebuilt or stopped.

To start developing, run:

```bash
waypoint-client start
```

### Developing on a Waypoint Container

On the first boot, the waypoint will build the image.

1. [Install the VSCode Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension.
2. Select `Dev containers: attach to a running container`. (<kbd>Command</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> on Mac)

Then, execute the following commands:

- Start background services (e.g., databases):

```bash
waypoint services
```

- Initialize environments:

```bash
waypoint init
```

or

```bash
waypoint init [product]
```

- Switch between products:

```bash
waypoint switch [product]
```

Now, you are ready to start coding. Treat the waypoint as a VM; you can make changes, set up git, etc. However, remember that updates to the waypoint will erase any changes not made in `/labs`, which is mounted to your local machine based on your initial configuration.

Mounts:

- **Code mount**: Your code is mounted so you can access it locally.
- **Secret mount**: A directory is used as a secret mount, and all files are loaded in with `source` as secrets.

## Waypoint Commands

### `waypoint-client` CLI

The waypoint-client CLI is for your local machine.

- `waypoint-client configure` to set up your waypoint-client and set the location for your secrets and code to be stored on your local machine. These will be mounted into the waypoint dev machine.
- `waypoint-client start` to start the docker image and begin coding. After running, use VSCode dev containers to connect to the waypoint.

### `waypoint` CLI

The waypoint CLI is for your waypoint dev machine.

- `waypoint services (start/stop/status)` to start, stop, or check the status of background services, such as PostgreSQL and Redis.
- Defaults to `start`
- `waypoint init (product)` to set up initial environments. This will clone corresponding repositories to `/labs/[product]`, migrate and populate the backend, and install frontend packages with `yarn`.
- You may omit the product name to initialize all products (recommended)
- `waypoint switch [product]` to switch environments. This will attempt to switch to a new VSCode window if you are using waypoint in a dev container

The following commands are done only in a product environment. (You must switch to some product for these to work)

- `waypoint sync [product]` refreshes backend dependencies for a particular product to be up to date to what the container currently specifies.
- `waypoint backend` to start the backend for your current product
- `waypoint frontend` to start the frontend for your current product

- Initialize a product environment:

```bash
waypoint init (product)
```

- Switch between products:

```bash
waypoint switch [product]
```

- Start development server:

```bash
waypoint start
```

- Start background services:

```bash
waypoint services
```
32 changes: 32 additions & 0 deletions docker/waypoint/database-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

# Start PostgreSQL service
sudo service postgresql start

# Start Redis server in the background
redis-server --daemonize yes

# PostgreSQL user and database details
PG_USER="postgres"
PG_PASSWORD="postgres"
PG_DATABASE="postgres"

# Alter the PostgreSQL user password
sudo -u postgres psql -v ON_ERROR_STOP=1 --username "$PG_USER" --dbname "$PG_DATABASE" <<-EOSQL
ALTER USER $PG_USER WITH PASSWORD '$PG_PASSWORD';
EOSQL

# Create a new PostgreSQL user "penn-courses" with the same password if it doesn't already exist
sudo -u postgres psql -v ON_ERROR_STOP=1 --username "$PG_USER" --dbname "$PG_DATABASE" <<-EOSQL
DO \$\$
BEGIN
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'penn-courses') THEN
CREATE USER "penn-courses" WITH PASSWORD '$PG_PASSWORD';
ALTER USER "penn-courses" WITH SUPERUSER;
END IF;
END
\$\$;
EOSQL

echo "PostgreSQL user password updated successfully."
60 changes: 60 additions & 0 deletions docker/waypoint/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

INSTALL_DIR="/usr/local/bin"
WAYPOINT_VERSION="v0.0.2.20"
GITHUB_ORG="pennlabs"
REPO_NAME="infrastructure"

OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
BINARY_SUFFIX=""
CWD=$(pwd)

case "$OS" in
linux*)
case "$ARCH" in
x86_64|amd64)
BINARY_SUFFIX="-linux-x86_64"
;;
*)
echo "Unsupported Linux architecture: $ARCH"
exit 1
;;
esac
;;
darwin*)
case "$ARCH" in
arm64|aarch64)
BINARY_SUFFIX="-macos-arm64"
;;
x86_64|amd64)
BINARY_SUFFIX="-macos-x86_64"
;;
*)
echo "Unsupported macOS architecture: $ARCH"
exit 1
;;
esac
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac

TMP_DIR=$(mktemp -d)
cd $TMP_DIR

echo "Downloading Waypoint for $OS $ARCH..."
curl -L "https://github.com/${GITHUB_ORG}/${REPO_NAME}/releases/download/${WAYPOINT_VERSION}/waypoint-client${BINARY_SUFFIX}" -o waypoint-client

chmod +x waypoint-client
sudo mv waypoint-client $INSTALL_DIR/

echo "Waypoint client installed successfully!"
echo "Run 'waypoint-client configure' to get started."
echo "Run 'waypoint-client --help' to see available commands."

rm -rf $TMP_DIR

cd $CWD
Loading
Loading