diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..b791cfda --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,18 @@ +ARG VARIANT=latest +FROM elixir:${VARIANT} + +RUN apt-get update && \ + apt-get install -y postgresql-client && \ + apt-get install -y inotify-tools && \ + apt-get install -y nodejs && \ + apt-get install -y git && \ + curl -L https://npmjs.org/install.sh | sh && \ + mix local.hex --force && \ + mix archive.install hex phx_new ${PHX_VERSION} --force && \ + mix local.rebar --force + +ENV APP_HOME /app +RUN mkdir $APP_HOME +WORKDIR $APP_HOME + +EXPOSE 4000 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..52ed6613 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,39 @@ +{ + "name": "Phoenix", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspace", + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "sqltools.connections": [{ + "name": "Container database", + "driver": "PostgreSQL", + "previewLimit": 50, + "server": "localhost", + "port": 5432, + "database": "postgres", + "username": "postgres", + "password": "postgres" + }] + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "dbaeumer.vscode-eslint", + "mtxr.sqltools", + "mtxr.sqltools-driver-pg", + "jakebecker.elixir-ls", + "mjmcloug.vscode-elixir" + ], + + // 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": "bash scripts/install.sh", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "node" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 00000000..b057feb9 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,43 @@ +version: '3' + +services: + app: + build: + context: . + dockerfile: Dockerfile + args: + VARIANT: latest + PHX_VERSION: 1.5.3 + + volumes: + - ..:/workspace:cached + - vscode-extension:/root/.vscode-server-insiders + + # 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 + + # Uncomment the next line to use a non-root user for all processes. + # user: node + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + db: + image: postgres:latest + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_DB: postgres + + # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward MongoDB locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + +volumes: + postgres-data: + vscode-extension: