-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57f7dd8
commit 2565fa6
Showing
4 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Same as production | ||
ARG VARIANT=22.04 | ||
FROM ubuntu:${VARIANT} | ||
|
||
ARG USERNAME=dev | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
curl \ | ||
xvfb \ | ||
git \ | ||
nano \ | ||
unzip \ | ||
bash-completion \ | ||
less \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Create the user with the same UID/GID as host user | ||
RUN groupadd --gid $USER_GID $USERNAME \ | ||
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ | ||
&& apt-get update \ | ||
&& apt-get install -y sudo \ | ||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME | ||
|
||
# Set up NVM and Node.js | ||
ENV NVM_DIR=/usr/local/nvm | ||
ENV NODE_VERSION=v20.16.0 | ||
RUN mkdir -p /usr/local/nvm \ | ||
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \ | ||
&& . $NVM_DIR/nvm.sh \ | ||
&& nvm install $NODE_VERSION \ | ||
&& nvm alias default $NODE_VERSION \ | ||
&& nvm use default \ | ||
&& chown -R $USERNAME:$USERNAME $NVM_DIR | ||
ENV NODE_PATH=/usr/local/nvm/versions/node/$NODE_VERSION/bin | ||
ENV PATH=$NODE_PATH:$PATH | ||
|
||
# Set up Bun | ||
USER $USERNAME | ||
WORKDIR /home/$USERNAME | ||
RUN curl -fsSL https://bun.sh/install | bash | ||
ENV BUN_PATH=/home/$USERNAME/.bun | ||
ENV PATH=$BUN_PATH/bin:$PATH | ||
|
||
# Set up bash | ||
RUN echo 'export PS1="\[\e[01;32m\]\u\[\e[m\]:\[\e[01;34m\]\w\[\e[m\]\$ "' >> ~/.bashrc \ | ||
&& echo "export PATH=\"$BUN_PATH/bin:\$PATH\"" >> ~/.bashrc \ | ||
&& echo 'export NVM_DIR="/usr/local/nvm"' >> ~/.bashrc \ | ||
&& echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bashrc | ||
|
||
# Create workspace directory with correct permissions | ||
USER root | ||
RUN mkdir -p /workspace \ | ||
&& chown $USERNAME:$USERNAME /workspace | ||
|
||
# Entrypoint script | ||
COPY <<-"EOF" /usr/local/bin/entrypoint.sh | ||
#!/bin/bash | ||
if [ "$1" = "dev" ]; then | ||
# If first argument is "dev", start the dev server with host binding | ||
. ~/.bashrc && exec bun dev --host 0.0.0.0 | ||
else | ||
# Otherwise, forward all arguments to bun | ||
. ~/.bashrc && exec bun "$@" | ||
fi | ||
EOF | ||
|
||
RUN chmod +x /usr/local/bin/entrypoint.sh | ||
|
||
USER $USERNAME | ||
WORKDIR /workspace | ||
ENV CONTAINER=true | ||
|
||
# Verify installations | ||
RUN . ~/.bashrc && bun --version && node --version | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
CMD ["dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "Cockpit Development", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"args": { | ||
"USERNAME": "dev", | ||
"USER_UID": "1000", | ||
"USER_GID": "1000" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint", | ||
"vue.volar", | ||
"bradlc.vscode-tailwindcss", | ||
"spencerwmiles.vscode-task-buttons" | ||
], | ||
"settings": { | ||
"task.quickOpen.detail": true, | ||
"task.quickOpen.skip": false, | ||
"terminal.integrated.defaultProfile.linux": "bash" | ||
} | ||
} | ||
}, | ||
"forwardPorts": [5173], | ||
"postCreateCommand": "git submodule update --init --recursive && bun install && exit 0", | ||
"remoteUser": "dev", | ||
"updateRemoteUserUID": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"VsCodeTaskButtons.showCounter": true, | ||
"VsCodeTaskButtons.tasks": [ | ||
{ | ||
"label": "🐳 Docker", | ||
"task": "🏗️ Build Docker Container", | ||
"tooltip": "Build the Docker container", | ||
"hide": "${env:REMOTE_CONTAINERS}" | ||
}, | ||
{ | ||
"label": "$(server-process) DevServer", | ||
"task": "🚀 Start Dev Server", | ||
"description": "$(debug-start) Start the development server" | ||
}, | ||
{ | ||
"label": "$(package) Dependencies", | ||
"tasks": [ | ||
{ | ||
"label": "📦 Install Dependencies", | ||
"task": "📦 Install Dependencies", | ||
"description": "$(package) Install project dependencies" | ||
}, | ||
{ | ||
"label": "🧹 Clean Install", | ||
"task": "🧹 Clean Install", | ||
"description": "$(trash) Remove and reinstall all dependencies" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "$(tools) Build", | ||
"tasks": [ | ||
{ | ||
"label": "🔨 Build Project", | ||
"task": "🔨 Build", | ||
"description": "$(gear) Build the project" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "$(beaker) Test", | ||
"task": "🧪 Run Tests", | ||
"tooltip": "🧪 Run project tests" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "🏗️ Build Docker Container", | ||
"type": "shell", | ||
"command": "echo 'Building Docker container...' && docker build -t bun-cockpit-container .devcontainer/ && echo '✅ Container built successfully!'", | ||
"problemMatcher": [], | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "shared", | ||
"showReuseMessage": false, | ||
"clear": true | ||
}, | ||
"group": "build", | ||
"options": { | ||
"env": { | ||
"INSIDE_CONTAINER": "${env:REMOTE_CONTAINERS}" | ||
} | ||
}, | ||
"runOptions": { | ||
"runOn": "default" | ||
} | ||
}, | ||
{ | ||
"label": "🚀 Start Dev Server", | ||
"type": "shell", | ||
"command": "if [ -z \"$CONTAINER\" ]; then docker run -it -v ${workspaceFolder}:/workspace -p 5173:5173 bun-cockpit-container dev; else bun dev --host 0.0.0.0; fi", | ||
"problemMatcher": [], | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "dedicated", | ||
"showReuseMessage": false, | ||
"clear": true, | ||
"close": false | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "📦 Install Dependencies", | ||
"type": "shell", | ||
"command": "if [ -z \"$CONTAINER\" ]; then docker run -v ${workspaceFolder}:/workspace bun-cockpit-container install; else bun install; fi", | ||
"problemMatcher": [], | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "shared", | ||
"showReuseMessage": false, | ||
"clear": true | ||
} | ||
}, | ||
{ | ||
"label": "🧪 Run Tests", | ||
"type": "shell", | ||
"command": "if [ -z \"$CONTAINER\" ]; then docker run -v ${workspaceFolder}:/workspace bun-cockpit-container test; else bun test; fi", | ||
"problemMatcher": [], | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "shared", | ||
"showReuseMessage": false, | ||
"clear": true | ||
} | ||
}, | ||
{ | ||
"label": "🔨 Build", | ||
"type": "shell", | ||
"command": "if [ -z \"$CONTAINER\" ]; then docker run -v ${workspaceFolder}:/workspace bun-cockpit-container run build; else bun run build; fi", | ||
"problemMatcher": [], | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "shared", | ||
"showReuseMessage": false, | ||
"clear": true | ||
} | ||
}, | ||
{ | ||
"label": "🧹 Clean Install", | ||
"type": "shell", | ||
"command": "if [ -z \"$CONTAINER\" ]; then docker run -v ${workspaceFolder}:/workspace bun-cockpit-container bash -c \"rm -rf node_modules bun.lockb && bun install\"; else rm -rf node_modules bun.lockb && bun install; fi", | ||
"problemMatcher": [], | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "shared", | ||
"showReuseMessage": false, | ||
"clear": true | ||
} | ||
} | ||
] | ||
} |