forked from hedyorg/hedy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHORE] Github Codespaces Setup (hedyorg#4025)
**Description** Adds a `.devcontainer` folder with a setup for Github Codespaces (and VS Code Remote Container). Getting started with Hedy development has never been easier.
- Loading branch information
Showing
5 changed files
with
153 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,51 @@ | ||
FROM python:3.9-slim as main | ||
|
||
# use a non-root user (https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user) | ||
ARG USERNAME=hedy | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
# Create the user | ||
RUN groupadd --gid $USER_GID $USERNAME \ | ||
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ | ||
# | ||
# [Optional] Add sudo support. Omit if you don't need to install software after connecting. | ||
&& apt-get update \ | ||
&& apt-get install -y sudo \ | ||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME | ||
|
||
# Install all binary dependencies (things that won't change due to our code changes) | ||
# git is needed / useful in github codespaces | ||
# make and gcc are needed for node-gyp package | ||
RUN apt-get install -y gcc git make g++ curl && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && apt-get install -y nodejs | ||
|
||
# Fix cypress dependencies | ||
# https://docs.cypress.io/guides/continuous-integration/introduction#Dependencies | ||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get install -y --no-install-recommends \ | ||
libgtk2.0-0 \ | ||
libgtk-3-0 \ | ||
libgbm-dev \ | ||
libnotify-dev \ | ||
libgconf-2-4 \ | ||
libnss3 \ | ||
libxss1 \ | ||
libasound2 \ | ||
libxtst6 xauth xvfb | ||
|
||
FROM main as node_builder | ||
WORKDIR /app | ||
COPY package* . | ||
RUN npm ci | ||
|
||
FROM main | ||
|
||
# Setup python packages | ||
COPY requirements.txt /tmp/requirements.txt | ||
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt | ||
|
||
# Copy node modules to a tmp folder | ||
COPY --from=node_builder /app/node_modules /var/tmp/node_modules | ||
|
||
EXPOSE 8080 | ||
ENV SHELL /bin/bash |
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,11 @@ | ||
#!/bin/bash | ||
set -e | ||
pre-commit install | ||
pybabel compile -f -d translations | ||
cp -r /var/tmp/node_modules . | ||
|
||
if [[ -z "${BASE_URL}" ]]; then | ||
echo "export BASE_URL=\"https://${CODESPACE_NAME}-8080.preview.app.github.dev\"" >> ~/.bashrc | ||
fi | ||
|
||
|
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,38 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. | ||
{ | ||
"name": "Hedy", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "dev", | ||
"workspaceFolder": "/workspace", | ||
"forwardPorts": [ | ||
8080, | ||
8081 | ||
], | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-python.python", | ||
"dirk-thomas.vscode-lark" | ||
], | ||
"settings": { | ||
"terminal.integrated.shell.linux": "bash", | ||
"terminal.integrated.profiles.linux": { | ||
"bash (container default)": { | ||
"path": "/bin/bash", | ||
"overrideName": true | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
"onCreateCommand": ".devcontainer/create.sh", | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
//"postCreateCommand": "", | ||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "hedy" | ||
} |
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,33 @@ | ||
# Based on https://devopstar.com/2022/01/03/cypress-testing-in-devcontainers-and-github-codespaces/ | ||
--- | ||
version: '3' | ||
|
||
services: | ||
dev: | ||
build: | ||
context: .. | ||
dockerfile: .devcontainer/Dockerfile | ||
command: sleep infinity | ||
environment: | ||
DISPLAY: ":14" | ||
LIBGL_ALWAYS_INDIRECT: 0 | ||
volumes: | ||
- ../:/workspace | ||
volumes_from: | ||
- x11-bridge:rw | ||
depends_on: | ||
- x11-bridge | ||
x11-bridge: | ||
# https://github.com/JAremko/docker-x11-bridge | ||
image: jare/x11-bridge | ||
volumes: | ||
- "/tmp/.X11-unix:/tmp/.X11-unix:rw" | ||
ports: | ||
- "8081:8081" | ||
restart: always | ||
environment: | ||
MODE: tcp | ||
XPRA_HTML: "yes" | ||
DISPLAY: ":14" | ||
XPRA_TCP_PORT: "8081" | ||
XPRA_PASSWORD: hedy # This password can be anything you want. |
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