-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update devcontainer configuration, add post-create and post-sta…
…rt scripts, and enhance README for setup instructions
- Loading branch information
1 parent
be52844
commit fbaf69e
Showing
5 changed files
with
99 additions
and
81 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 |
---|---|---|
@@ -1,46 +1,42 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||
{ | ||
"name": "Ubuntu", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"dockerComposeFile": "docker-compose.yml", | ||
"name": "Dev Container", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "devcontainer", | ||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", | ||
"features": { | ||
"ghcr.io/va-h/devcontainers-features/uv:1": { | ||
"version": "latest" | ||
}, | ||
"ghcr.io/itsmechlark/features/postgresql:1": { | ||
"version": "latest" | ||
}, | ||
"ghcr.io/devcontainers/features/github-cli:1": { | ||
} | ||
}, | ||
|
||
"features": { | ||
"ghcr.io/va-h/devcontainers-features/uv:1": { | ||
"version": "latest" | ||
}, | ||
"ghcr.io/itsmechlark/features/postgresql:1": { | ||
"version": "latest" | ||
}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {}, | ||
"ghcr.io/devcontainers/features/node:1": { | ||
"version": "18" | ||
} | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
"forwardPorts": [5000, 8081], | ||
|
||
"containerEnv": { | ||
"DATABASE_URL": "postgresql://postgres:postgres@db:5432/postgres", | ||
"EXPO_PUBLIC_API_URL": "http://localhost:5000/api" | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [5000], | ||
"containerEnv": { | ||
"DATABASE_URL": "postgresql://postgres:postgres@db:5432/postgres" | ||
}, | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "/bin/bash -c 'if [ ! -f ${containerWorkspaceFolder}/backend/.env ]; then echo \"Setting up environment variables...\"; read -p \"Enter Gmail address: \" email; echo \"Enter Gmail app password: \"; read -s password; echo; echo \"SECRET_KEY=$(openssl rand -base64 32)\" > ${containerWorkspaceFolder}/backend/.env; echo \"TOKEN_SECRET_KEY=$(openssl rand -base64 32)\" >> ${containerWorkspaceFolder}/backend/.env; echo \"MAIL_SERVER=smtp.gmail.com\" >> ${containerWorkspaceFolder}/backend/.env; echo \"MAIL_PORT=587\" >> ${containerWorkspaceFolder}/backend/.env; echo \"MAIL_USE_TLS=True\" >> ${containerWorkspaceFolder}/backend/.env; echo \"MAIL_USERNAME=$email\" >> ${containerWorkspaceFolder}/backend/.env; echo \"MAIL_PASSWORD=$password\" >> ${containerWorkspaceFolder}/backend/.env; echo \"MAIL_DEFAULT_SENDER=$email\" >> ${containerWorkspaceFolder}/backend/.env; fi'", | ||
"updateContentCommand": "cd ${containerWorkspaceFolder}/backend && uv sync", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
"remoteUser": "root", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"charliermarsh.ruff" | ||
] | ||
} | ||
} | ||
"postCreateCommand": "bash ${containerWorkspaceFolder}/.devcontainer/scripts/post-create.sh", | ||
"postStartCommand": "bash ${containerWorkspaceFolder}/.devcontainer/scripts/post-start.sh", | ||
|
||
"remoteUser": "root", | ||
|
||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"charliermarsh.ruff", | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode" | ||
] | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
WORKSPACE_ROOT="/workspaces/pharmacy-app" | ||
|
||
if [ ! -f "${WORKSPACE_ROOT}/backend/.env" ]; then | ||
echo "Setting up environment variables..." | ||
|
||
read -p "Enter Gmail address: " email | ||
echo "Enter Gmail app password: " | ||
read -s password | ||
echo | ||
|
||
cat > "${WORKSPACE_ROOT}/backend/.env" << ENVEOF | ||
SECRET_KEY=$(openssl rand -base64 32) | ||
TOKEN_SECRET_KEY=$(openssl rand -base64 32) | ||
MAIL_SERVER=smtp.gmail.com | ||
MAIL_PORT=587 | ||
MAIL_USE_TLS=True | ||
MAIL_USERNAME=$email | ||
MAIL_PASSWORD=$password | ||
MAIL_DEFAULT_SENDER=$email | ||
ENVEOF | ||
fi | ||
|
||
if [ -f "${WORKSPACE_ROOT}/frontend/package.json" ]; then | ||
echo "Installing frontend dependencies..." | ||
cd "${WORKSPACE_ROOT}/frontend" | ||
npm install | ||
else | ||
echo "Error: ${WORKSPACE_ROOT}/frontend/package.json not found" | ||
fi | ||
|
||
if [ -f "${WORKSPACE_ROOT}/backend/pyproject.toml" ]; then | ||
echo "Installing backend dependencies..." | ||
cd "${WORKSPACE_ROOT}/backend" | ||
uv sync | ||
else | ||
echo "Error: ${WORKSPACE_ROOT}/backend/pyproject.toml not found" | ||
fi |
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 @@ | ||
#!/bin/bash | ||
|
||
WORKSPACE_ROOT="/workspaces/pharmacy-app" | ||
|
||
if [ -f "${WORKSPACE_ROOT}/backend/pyproject.toml" ]; then | ||
echo "Running database migrations..." | ||
cd "${WORKSPACE_ROOT}/backend" | ||
uv run flask db upgrade | ||
uv run flask seed products | ||
else | ||
echo "Error: ${WORKSPACE_ROOT}/backend/pyproject.toml not found" | ||
fi |
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