diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..c1ca9c5 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,10 @@ +FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18 + +RUN usermod -l zipline node \ + && groupmod -n zipline node \ + && usermod -d /home/zipline zipline \ + && echo "zipline ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/zipline \ + && chmod 0440 /etc/sudoers.d/zipline \ + && sudo apt-get update && apt-get install gnupg2 -y + +USER zipline \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5058260..16432d7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,12 +2,15 @@ "name": "Zipline Codespace", "dockerComposeFile": "docker-compose.yml", "service": "app", - "workspaceFolder": "/workspace", - "forwardPorts": [3000, 5432], + "workspaceFolder": "/zipline", "features": { - "ghcr.io/devcontainers/features/common-utils:2": {}, - "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, - "ghcr.io/devcontainers/features/node:1": {} + "ghcr.io/devcontainers/features/common-utils:2": { + "username": "zipline" + }, + "ghcr.io/devcontainers/features/docker-in-docker:1": { + "dockerDashComposeVersion": "v2", + "installDockerBuildx": true + } }, "customizations": { "vscode": { @@ -20,22 +23,34 @@ }, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, - "files.autoSave": "afterDelay" + "files.autoSave": "afterDelay", + "terminal.integrated.persistentSessionReviveProcess": "never", + "terminal.integrated.defaultProfile.linux": "zsh", + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/bin/zsh", + "env": { + "ZSH_THEME": "devcontainers" + } + } + } }, "extensions": ["prisma.prisma", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint"] } }, "remoteUser": "zipline", + "updateRemoteUserUID": true, "remoteEnv": { "CORE_DATABASE_URL": "postgres://postgres:postgres@localhost/zip10" }, "portsAttributes": { - "3000": { - "label": "Zipline", + "3000": { + "label": "Zipline", "onAutoForward": "openBrowser" - }, - "5432": { - "label": "Postgres" - } - } + }, + "5432": { + "label": "Postgres" + } + }, + "postCreateCommand": "sudo chown -R zipline:zipline /zipline && yarn install" } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 056c5f1..a908702 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,12 +1,14 @@ version: '3.8' services: app: - image: mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18 + build: + context: ./ + dockerfile: Dockerfile volumes: - - ..:/workspace:cached - network_mode: service:db + - ../:/zipline:cached + - uploads:/zipline/uploads + - node_modules:/zipline/node_modules command: sleep infinity - user: zipline db: image: postgres:latest restart: unless-stopped @@ -19,4 +21,5 @@ services: volumes: pg_data: - \ No newline at end of file + uploads: + node_modules: \ No newline at end of file