Setup GitHub Codespaces

This commit is contained in:
Quentin Gliech
2021-08-14 20:50:07 +00:00
committed by GitHub
parent 7068c62446
commit 705b18a9f8
3 changed files with 82 additions and 0 deletions

8
.devcontainer/Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/vscode/devcontainers/rust:0-1
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends postgresql-client
# TODO: pre-build custom images, those take too much time
#RUN cargo install sqlx-cli --no-default-features --features postgres
#RUN cargo install cargo-edit

View File

@@ -0,0 +1,40 @@
{
"name": "Rust",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"postCreateCommand": "SQLX_OFFLINE=1 cargo run -- database migrate",
"settings": {
"lldb.executable": "/usr/bin/lldb",
"sqltools.connections": [{
"name": "Container database",
"driver": "PostgreSQL",
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"database": "postgres",
"username": "postgres",
"password": "postgres"
}],
"files.watcherExclude": {
"**/target/**": true
}
},
"forwardPorts": [8080],
"portsAttributes": {
"8080": {
"label": "Application"
}
},
"extensions": [
"bungcip.better-toml",
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor",
"matklad.rust-analyzer",
"mtxr.sqltools",
"mtxr.sqltools-driver-pg"
]
}

View File

@@ -0,0 +1,34 @@
version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
volumes:
- ..:/workspace:cached
environment:
# FIXME: sqlx-cli and the app use different URIs
DATABASE_URL: postgresql://postgres:postgres@localhost/postgres
MAS_DATABASE_URI: postgresql://postgres:postgres@localhost/postgres
MAS_COOKIES_SECRET: a093e76c2ddc87d9de7afc1f9059d60a12176b2cdf8966029c00bc2146518a61
# 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
db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
volumes:
postgres-data: