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

Initial setup for devcontainers for OSE project #556

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/duduribeiro/devcontainer-features/neovim:1": {
"version": "nightly"
}
Comment on lines +8 to +10
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if there's a way to add LazyVim or Astro to this config?

},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
30000
],
// Use 'postCreateCommand' to run commands after the container is created.
// Ask the user to provide foundry install url; download and unpack foundry;
// Start the foundry server; link the workspace to the foundry's data/systems/D35E folder
"postCreateCommand": "./.devcontainer/setup-foundry.sh",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root"
}
29 changes: 29 additions & 0 deletions .devcontainer/setup-foundry.sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

We ought to prompt for a license key, too, or have some way to easily pull it from somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can open Foundry then using the provided launch.json (or just by running a command in the devcontainer) and it will ask you for serial number. I don't know how to provide it differently, but I will take a look

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

if [ ! -d "/home/node/.foundryvtt" ]; then
# Check if there is a .foundrycache folder in the workspace and it has at least one file
if [ -d "/workspaces/ose/.foundrycache" ] && [ "$(ls -A /workspaces/ose/.foundrycache)" ]; then
# Find the newest file in the .foundrycache directory
cachedFoundryFile=$(ls -t /workspaces/ose/.foundrycache/*.zip | head -1)
echo "Using cached FoundryVTT file $cachedFoundryFile"
cp "/workspaces/ose/.foundrycache/$(basename "$cachedFoundryFile")" .
foundryFile=$(basename "$cachedFoundryFile")
else
echo 'Please provide the FoundryVTT timed URL from https://foundryvtt.com/. Select the Linux/Node.js operating system.'
read -p 'FoundryVTT URL: ' foundryUrl
# Get the filename from the URL
foundryFile=$(basename "$foundryUrl" | cut -d'?' -f1)
echo "Downloading $foundryFile"
curl -L "$foundryUrl" -o "$foundryFile"
echo "Copying $foundryFile to .foundrycache"
mkdir -p /workspaces/ose/.foundrycache
cp "$foundryFile" /workspaces/ose/.foundrycache
fi
# quietly unzip the file
echo "Unzipping $foundryFile"
unzip "$foundryFile" -d /home/node/.foundryvtt > /dev/null
rm "$foundryFile"
mkdir -p /home/node/.foundrydata/Data/systems
fi

ln -s /workspaces/ose /home/node/.foundrydata/Data/systems/ose-dev
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto
system.json filter=mungePackageID
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ ose-dev.lock
dist
.DS_Store
.env
.foundrycache
foundry.zip
53 changes: 53 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
// Użyj funkcji IntelliSense, aby uzyskać informacje o możliwych atrybutach.
// Najedź kursorem, aby wyświetlić opisy istniejących atrybutów.
// Aby uzyskać więcej informacji, odwiedź stronę: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Build & Watch via NPM",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"build:watch"
],
"cwd": "${workspaceFolder}",
"skipFiles": [
"<node_internals>/**"
]
},
{
"type": "node",
"request": "launch",
"name": "Launch FoundryVTT",
"program": "/home/node/.foundryvtt/resources/app/main.js",
"args": [
"--dataPath=/home/node/.foundrydata"
],
"cwd": "${workspaceFolder}",
"runtimeExecutable": "node",
"runtimeArgs": [
"--inspect=9229"
],
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"<node_internals>/**"
]
}
],
"compounds": [
{
"name": "Build & Launch FoundryVTT",
"configurations": [
"Build & Watch via NPM",
"Launch FoundryVTT"
]
}
]
}