From 5647ac6b01e46271d8f76d19161b8964bfab3aaf Mon Sep 17 00:00:00 2001 From: tkt <37575408+tktcorporation@users.noreply.github.com> Date: Mon, 10 Oct 2022 07:53:40 +0000 Subject: [PATCH] :technologist: devcontainer settings --- .devcontainer/devcontainer.json | 52 +++++++++++++++++++++++++++++++++ .env.defaults | 2 +- Dockerfile | 10 +++++++ docker-compose.yml | 42 ++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..05dd62c90 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,52 @@ +{ + "name": "redwoodjs-v3-tutrial-2nd", + "image": "mcr.microsoft.com/vscode/devcontainers/universal:linux", + + // Set *default* container specific settings.json values on container create. + "settings": { + "runOnSave.commands": [ + { + "globMatch": "**/*", + "command": "docker-compose exec -T app /bin/bash -c \"dum rw lint --fix\"", + "runIn": "backend" + } + ] + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-azuretools.vscode-docker", + "GitHub.copilot", + "donjayamanne.githistory", + "eamodio.gitlens", + "mhutchie.git-graph", + "steoates.autoimport", + "pucelle.run-on-save", + "Prisma.prisma", + "WallabyJs.console-ninja", + "antfu.iconify", + "Atishay-Jain.All-Autocomplete", + "usernamehw.errorlens", + "GraphQL.vscode-graphql", + "dbaeumer.vscode-eslint", + "eamodio.gitlens", + "ofhumanbondage.react-proptypes-intellisense", + "mgmcdermott.vscode-language-babel", + "wix.vscode-import-cost", + "pflannery.vscode-versionlens", + "editorconfig.editorconfig", + "prisma.prisma", + "WakaTime.vscode-wakatime" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "gh extension install davidraviv/gh-clean-branches", + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "features": { + "homebrew": "latest" + } +} diff --git a/.env.defaults b/.env.defaults index aa277779e..e8189de21 100644 --- a/.env.defaults +++ b/.env.defaults @@ -4,7 +4,7 @@ # into version control. # schema.prisma defaults -DATABASE_URL=file:./dev.db +# DATABASE_URL=file:./dev.db # location of the test database for api service scenarios (defaults to ./.redwood/test.db if not set) # TEST_DATABASE_URL=file:./.redwood/test.db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..be78b4da2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:18.10.0-bullseye-slim AS build-env + +ENV LC_ALL=C.UTF-8 + +RUN apt-get update && \ + apt-get install -y \ + curl \ + git + +RUN curl -sSL https://bina.egoist.sh/egoist/dum | bash diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..edb8b434f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +version: "3.8" +services: + app: + command: /bin/bash -c "dum i && dum rw dev" + build: . + working_dir: /app + volumes: + - .:/app + environment: + - RWJS_DEV_API_URL=${RWJS_DEV_API_URL:-http://localhost} + - SESSION_SECRET=${SESSION_SECRET:-dummy} + - DATABASE_URL=postgres://postgres:postgres@db:5432/postgres?connection_limit=1 + - TEST_DATABASE_URL=postgres://postgres:postgres@db-test:5432/postgres_test?connection_limit=1 + ports: + - "7910:7910" # storybook + - "8910:8910" # redwoodjs web + - "8911:8911" + - "18911:18911" + - "5555:5555" + depends_on: + - db + - db-test + db: + image: postgres:14 + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=postgres + volumes: + - ./redwoodblog/.db/data:/var/lib/postgresql/data + ports: + - "5432:5432" + db-test: + image: postgres:14 + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=postgres_test + volumes: + - ./redwoodblog/.db/data-test:/var/lib/postgresql/data + ports: + - "5433:5432"