-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* include postgres in dev container * install postgres * postgres settings * ports * add env vars * use new test python job * postgres 17 * install psql * remove args * reference example * set to main Co-Authored-By: --global <--global>
- Loading branch information
Showing
8 changed files
with
159 additions
and
8 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,6 @@ | ||
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04 | ||
|
||
# Install PostgreSQL (psql) client. | ||
RUN apt-get update && \ | ||
export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get -y install --no-install-recommends postgresql-client |
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,25 @@ | ||
version: "3" | ||
|
||
services: | ||
app: | ||
build: | ||
context: .. | ||
dockerfile: .devcontainer/Dockerfile | ||
volumes: | ||
- ..:/codeforlife-workspace:cached | ||
# Overrides default 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:17 | ||
restart: unless-stopped | ||
volumes: | ||
- ../scripts/database:/docker-entrypoint-initdb.d | ||
- ../.postgres-data:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_MULTIPLE_DATABASES: contributor,portal,template | ||
POSTGRES_USER: root | ||
POSTGRES_PASSWORD: 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# This file was taken from: | ||
# https://github.com/mrts/docker-postgresql-multiple-databases/tree/dfc6df914b031c0b1de017248e50914013734b38 | ||
|
||
set -e | ||
set -u | ||
|
||
function create_user_and_database() { | ||
local database=$1 | ||
echo " Creating user and database '$database'" | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | ||
CREATE USER $database; | ||
CREATE DATABASE $database; | ||
GRANT ALL PRIVILEGES ON DATABASE $database TO $database; | ||
EOSQL | ||
} | ||
|
||
if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then | ||
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES" | ||
for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do | ||
create_user_and_database $db | ||
done | ||
echo "Multiple databases created" | ||
fi |