diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..bf2488f --- /dev/null +++ b/.devcontainer/Dockerfile @@ -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" ] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..53951da --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -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" +} diff --git a/.devcontainer/docker-entrypoint.sh b/.devcontainer/docker-entrypoint.sh new file mode 100755 index 0000000..60d5a1c --- /dev/null +++ b/.devcontainer/docker-entrypoint.sh @@ -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 "$@" diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100755 index 0000000..f553ae3 --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# install module dependencies +go get + +# install clipboard +go install golang.design/x/clipboard/cmd/gclip@latest