-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add devcontainer support (#234)
* style: format * feat: devcontainer * feat: minio * fix: pgadmin password * fix: remove `just env` * feat: adjust configurations * feat: custom docker image * fix: direnv * fix: initialize minio
- Loading branch information
Showing
17 changed files
with
222 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
POSTGRES_USER=boluo | ||
POSTGRES_PASSWORD=boluo | ||
PGADMIN_DEFAULT_EMAIL=[email protected] | ||
PGADMIN_DEFAULT_PASSWORD=boluo | ||
PGADMIN_LISTEN_PORT=4841 | ||
MINIO_ROOT_USER=boluo | ||
MINIO_ROOT_PASSWORD=boluo-development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM ubuntu:latest | ||
RUN apt update -y | ||
RUN apt install -y curl xz-utils git && mkdir /nix | ||
RUN \ | ||
useradd -m -s /bin/bash -u 1000 dev;\ | ||
chown dev /nix;\ | ||
mkdir -p /etc/nix;\ | ||
echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf | ||
ENV USER=dev | ||
USER dev | ||
WORKDIR /home/dev | ||
RUN curl -L https://nixos.org/nix/install | sh -s -- --no-daemon; | ||
ENV PATH="/home/dev/.nix-profile/bin:${PATH}" | ||
|
||
ARG PNPM_STORE_DIR=/home/dev/.local/share/pnpm | ||
ENV PNPM_STORE_DIR=${PNPM_STORE_DIR} | ||
RUN mkdir -p "${PNPM_STORE_DIR}" | ||
COPY --chown=dev:dev flake.lock flake.nix rust-toolchain.toml ./ | ||
RUN nix develop --command bash -c "pnpm config set store-dir ${PNPM_STORE_DIR}" && rm flake.lock flake.nix rust-toolchain.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node-postgres | ||
{ | ||
"name": "Boluo", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "app", | ||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/christophermacgown/devcontainer-features/direnv:1": {} | ||
}, | ||
|
||
// Configure tool-specific properties. | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"EditorConfig.EditorConfig", | ||
"bradlc.vscode-tailwindcss", | ||
"dprint.dprint", | ||
"rust-lang.rust-analyzer", | ||
"mkhl.direnv", | ||
"dbaeumer.vscode-eslint" | ||
] | ||
} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// This can be used to network with other containers or with the host. | ||
"forwardPorts": [3000, 4841, 9000, 9090, 8080], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "cp .env.local.example .env.local && direnv allow", | ||
|
||
// More info: https://aka.ms/dev-containers-non-root. | ||
"remoteUser": "dev", | ||
"containerUser": "dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
version: '3.8' | ||
|
||
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.) | ||
|
||
redis: | ||
image: redis | ||
restart: unless-stopped | ||
|
||
db: | ||
image: postgres:latest | ||
restart: unless-stopped | ||
volumes: | ||
- postgres-data:/var/lib/postgresql/data | ||
- ../apps/server/schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro | ||
environment: | ||
- POSTGRES_USER=${POSTGRES_USER} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
|
||
db-test: | ||
image: postgres:latest | ||
restart: unless-stopped | ||
volumes: | ||
- ../apps/server/schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro | ||
environment: | ||
- POSTGRES_USER=${POSTGRES_USER} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
|
||
pgadmin: | ||
image: dpage/pgadmin4 | ||
restart: unless-stopped | ||
volumes: | ||
- ./servers.json:/pgadmin4/servers.json:ro | ||
depends_on: | ||
- db | ||
- db-test | ||
environment: | ||
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL} | ||
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD} | ||
- PGADMIN_LISTEN_PORT=${PGADMIN_LISTEN_PORT} | ||
- PGADMIN_CONFIG_SERVER_MODE=FALSE | ||
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
network_mode: service:db | ||
|
||
store: | ||
image: quay.io/minio/minio | ||
restart: unless-stopped | ||
network_mode: service:db | ||
volumes: | ||
- minio-data:/data | ||
environment: | ||
- MINIO_ROOT_USER=${MINIO_ROOT_USER} | ||
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD} | ||
command: server /data --console-address ":9090" | ||
|
||
|
||
store-init: | ||
image: quay.io/minio/mc | ||
network_mode: service:db | ||
depends_on: | ||
- store | ||
entrypoint: > | ||
/bin/sh -c " | ||
sleep 10; | ||
/usr/bin/mc config host add devminio http://127.0.0.1:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD}; | ||
/usr/bin/mc rm -r --force devminio/boluo; | ||
/usr/bin/mc mb devminio/boluo; | ||
/usr/bin/mc anonymous set public devminio/boluo; | ||
exit 0; | ||
" | ||
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. | ||
# (Adding the "ports" property to this file will not forward from a Codespace.) | ||
|
||
volumes: | ||
nix-store: | ||
postgres-data: | ||
minio-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"Servers": { | ||
"1": { | ||
"Name": "boluo", | ||
"Group": "Servers", | ||
"Host": "db", | ||
"Port": 5432, | ||
"MaintenanceDB": "postgres", | ||
"Username": "boluo", | ||
"UseSSHTunnel": 0, | ||
"TunnelPort": "22", | ||
"TunnelAuthentication": 0, | ||
"KerberosAuthentication": false, | ||
"ConnectionParameters": { | ||
"sslmode": "prefer", | ||
"connect_timeout": 10 | ||
}, | ||
"PasswordExecCommand": "echo $POSTGRES_PASSWORD" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
DATABASE_URL=postgresql://boluo:boluo@db/boluo?sslmode=disable | ||
TEST_DATABASE_URL=postgresql://boluo:boluo@db-test/boluo?sslmode=disable | ||
REDIS_URL=redis://redis:6379 | ||
BACKEND_URL=http://127.0.0.1:3000 | ||
|
||
SECRET=SOME_SECRET | ||
S3_ACCESS_KEY_ID=boluo | ||
S3_SECRET_ACCESS_KEY=boluo-development | ||
S3_ENDPOINT_URL=http://127.0.0.1:9000 | ||
S3_BUCKET_NAME=boluo | ||
|
||
PUBLIC_MEDIA_URL=http://127.0.0.1:9000/boluo |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.