Gets docker-compose working.
You'll need to add a .env file to the same directory as the docker-compose.yml file that sets the values for DB_USER and DB_PASS.
This commit is contained in:
parent
ec4df2b3fa
commit
e1e866a2b3
|
@ -233,3 +233,5 @@ fabric.properties
|
|||
|
||||
# End of https://www.gitignore.io/api/flask,eclipse,intellij,sonarqube,visualstudiocode
|
||||
*.db
|
||||
postgres/var/
|
||||
.env
|
||||
|
|
|
@ -4,4 +4,4 @@ basedir = os.path.abspath(os.path.dirname(__file__))
|
|||
NAME = "CR Connect Workflow"
|
||||
CORS_ENABLED = False
|
||||
DEVELOPMENT = True
|
||||
SQLALCHEMY_DATABASE_URI = "postgresql://postgres:docker@localhost/crc"
|
||||
SQLALCHEMY_DATABASE_URI = "postgresql://crc_user:crc_pass@localhost:5432/crc_dev"
|
||||
|
|
|
@ -5,4 +5,4 @@ NAME = "CR Connect Workflow"
|
|||
CORS_ENABLED = False
|
||||
DEVELOPMENT = True
|
||||
TESTING = True
|
||||
SQLALCHEMY_DATABASE_URI = "postgresql://postgres:docker@localhost/postgres"
|
||||
SQLALCHEMY_DATABASE_URI = "postgresql://crc_user:crc_pass@localhost:5432/crc_test"
|
||||
|
|
|
@ -23,8 +23,6 @@ def update_file_from_request(file_model):
|
|||
# Verify the extension
|
||||
basename, file_extension = os.path.splitext(file.filename)
|
||||
file_extension = file_extension.lower().strip()[1:]
|
||||
print('\n\n\n', 'file_extension = "%s"' % file_extension, '\n\n\n')
|
||||
print('FileType._member_names_', FileType._member_names_)
|
||||
if file_extension not in FileType._member_names_:
|
||||
return ApiErrorSchema().dump(ApiError('unknown_extension',
|
||||
'The file you provided does not have an accepted extension:' +
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
psql -h localhost -U postgres -d postgres
|
||||
#psql -h localhost -U postgres -d postgres
|
||||
#psql -h localhost -U crc_user -d crc_test
|
||||
psql -h localhost -U crc_user -d crc_dev
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
version: "3.7"
|
||||
services:
|
||||
db:
|
||||
image: postgres
|
||||
volumes:
|
||||
- ./pg-init-scripts/initdb.sh:/docker-entrypoint-initdb.d/initdb.sh
|
||||
- $HOME/docker/volumes/postgres:/var/lib/postgresql/data
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
- POSTGRES_USER=${DB_USER}
|
||||
- POSTGRES_PASSWORD=${DB_PASS}
|
||||
- POSTGRES_MULTIPLE_DATABASES=crc_dev,crc_test
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
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
|
|
@ -1,3 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
docker stop postgres_db_1
|
||||
mkdir -p $HOME/docker/volumes/postgres
|
||||
docker pull postgres:latest
|
||||
docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres
|
||||
#docker pull postgres:latest
|
||||
#docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres
|
||||
docker-compose -f docker-compose.yml up --no-start
|
||||
docker-compose -f docker-compose.yml start
|
||||
|
|
|
@ -1 +1 @@
|
|||
docker stop pg-docker
|
||||
docker stop postgres_db_1
|
||||
|
|
Loading…
Reference in New Issue