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 devcontainer configuration #53

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG VARIANT=1
FROM mcr.microsoft.com/devcontainers/go:${VARIANT}

RUN apt-get update && apt-get install -y --no-install-recommends \
libegl1-mesa-dev \
libgles2-mesa-dev \
libx11-dev \
xvfb \
&& rm -rf /var/lib/apt/lists/*

# run virtual display init on start of the container
COPY .devcontainer/docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT [ "/docker-entrypoint.sh" ]

# keep the container running since the devcontainer will start its own processes
CMD [ "sleep", "infinity" ]
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "golang.design: clipboard",
"build": {
"context": "..",
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "1.21-bookworm"
}
},
// Install dependencies and other setup tasks
"postCreateCommand": ".devcontainer/setup.sh",
// Allow the Dockerfile's command to run (creates virtual display for X11 to support clipboard)
"overrideCommand": false,
"remoteUser": "vscode"
}
12 changes: 12 additions & 0 deletions .devcontainer/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

echo "Running docker-entrypoint.sh"

# create a virtual frame buffer for X11
nohup Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &

export DISPLAY=:99.0
echo "export DISPLAY=:99.0" > /etc/profile.d/01-export-virtual-display.sh
chmod +x /etc/profile.d/01-export-virtual-display.sh

exec "$@"
7 changes: 7 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# install module dependencies
go get

# install clipboard
go install golang.design/x/clipboard/cmd/gclip@latest