From c89222598ea2fb0e3d25765885f690a9550cf7a6 Mon Sep 17 00:00:00 2001 From: CEE Date: Mon, 28 Oct 2024 10:47:46 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20devcontainer=20=EB=8B=A4=EB=A5=B8?= =?UTF-8?q?=EB=8D=B0=EC=84=9C=20=EC=93=B0=EB=8D=98=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80.=20=ED=85=8C=EC=8A=A4=ED=8A=B8=ED=95=84?= =?UTF-8?q?=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/Dockerfile | 15 ++++++++ .devcontainer/create-db-user.sql | 2 + .devcontainer/devcontainer.json | 33 ++++++++++++++++ .devcontainer/docker-compose.yml | 66 ++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/create-db-user.sql create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..721741f --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,15 @@ +FROM ghcr.io/devcontainers/templates/go-postgres:4.1.0 + +# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service +# The value is a comma-separated list of allowed domains +ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev,.preview.app.github.dev,.app.github.dev" + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install additional gems. +# RUN su vscode -c "gem install " + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.devcontainer/create-db-user.sql b/.devcontainer/create-db-user.sql new file mode 100644 index 0000000..8623d49 --- /dev/null +++ b/.devcontainer/create-db-user.sql @@ -0,0 +1,2 @@ +CREATE USER dev_proxynd_user CREATEDB; +CREATE DATABASE de_proxynd_db WITH OWNER dev_proxynd_user; diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..230ebd6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres +{ + "name": "Go & Postgres", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // "features": { + // "ghcr.io/itsmechlark/features/postgresql:1": { + // "version": "16" + // }, + // "ghcr.io/itsmechlark/features/redis-server:1": { + // "version": "7" + // }, + // "ghcr.io/georgofenbeck/features/thefuck-pipx:1": {} + // } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // This can be used to network with other containers or the host. + // "forwardPorts": [3000, 5432], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "bundle install && rake db:setup", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..cd1de35 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,66 @@ +version: '3' + +services: + app: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + + volumes: + - ../..:/workspaces:cached + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + network_mode: service:db + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + profiles: + - '' + - app + - all + + db: + image: postgres:16 + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + - ./create-db-user.sql:/docker-entrypoint-initdb.d/create-db-user.sql + environment: + POSTGRES_USER: postgres + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + # Your config/database.yml should use the user and password you set here, + # and host "db" (as that's the name of this service). You can use whatever + # database name you want. Use `bin/rails db:prepare` to create the database. + # + # Example: + # + # development: + # <<: *default + # host: db + # username: postgres + # password: postgres + # database: myapp_development + + # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + profiles: + - '' + - backend + - all + + mailslurper: + image: oryd/mailslurper:latest-smtps + ports: + - '4436:4436' + - '4437:4437' + profiles: + - '' + - backend + - all + +volumes: + postgres-data: