update db-seed
This commit is contained in:
10
db-seed/Dockerfile
Normal file
10
db-seed/Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM postgres:16
|
||||||
|
|
||||||
|
WORKDIR /seed
|
||||||
|
|
||||||
|
COPY equipment-import.sql /seed/equipment-import.sql
|
||||||
|
COPY db-seed/import.sh /seed/import.sh
|
||||||
|
|
||||||
|
RUN chmod +x /seed/import.sh
|
||||||
|
|
||||||
|
CMD ["/seed/import.sh"]
|
||||||
13
db-seed/import.sh
Normal file
13
db-seed/import.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
: "${POSTGRES_USER:=postgres}"
|
||||||
|
: "${POSTGRES_DB:=toir}"
|
||||||
|
: "${PGPASSWORD:=change-me}"
|
||||||
|
|
||||||
|
until pg_isready -h postgres -U "$POSTGRES_USER" -d "$POSTGRES_DB" >/dev/null 2>&1; do
|
||||||
|
echo "waiting for postgres..."
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
psql -h postgres -U "$POSTGRES_USER" -d "$POSTGRES_DB" -v ON_ERROR_STOP=1 -f /seed/equipment-import.sql
|
||||||
@@ -57,7 +57,9 @@ services:
|
|||||||
- proxy
|
- proxy
|
||||||
|
|
||||||
db-seed:
|
db-seed:
|
||||||
image: postgres:16
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: db-seed/Dockerfile
|
||||||
container_name: toir-light-db-seed
|
container_name: toir-light-db-seed
|
||||||
restart: "no"
|
restart: "no"
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -67,14 +69,6 @@ services:
|
|||||||
PGPASSWORD: ${POSTGRES_PASSWORD:-change-me}
|
PGPASSWORD: ${POSTGRES_PASSWORD:-change-me}
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-toir}
|
POSTGRES_DB: ${POSTGRES_DB:-toir}
|
||||||
volumes:
|
|
||||||
- ./equipment-import.sql:/seed/equipment-import.sql:ro
|
|
||||||
command:
|
|
||||||
[
|
|
||||||
"sh",
|
|
||||||
"-c",
|
|
||||||
"psql -h postgres -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\" -v ON_ERROR_STOP=1 -f /seed/equipment-import.sql",
|
|
||||||
]
|
|
||||||
networks:
|
networks:
|
||||||
- toir-light
|
- toir-light
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user