-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.dbinit
37 lines (26 loc) · 905 Bytes
/
Dockerfile.dbinit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# This file is used to create a Docker image that will be used to initialize the database for Airbyte
FROM debian:12.6-slim
LABEL authors="Romaric P"
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
ARG DATABASE_USER
ENV DATABASE_USER=$DATABASE_USER
# Install the necessary packages
RUN apt update && apt install -y \
postgresql-client \
&& apt clean
WORKDIR /app
RUN cat <<EOF > init_db.sh
#!/bin/bash
set -e
# Create the init.sql file
echo "CREATE DATABASE airbyte IF NOT EXISTS;" > init.sql
echo "GRANT ALL PRIVILEGES ON DATABASE airbyte to $DATABASE_URL;" >> init.sql
echo "CREATE DATABASE temporal_visibility IF NOT EXISTS;" >> init.sql
echo "GRANT ALL PRIVILEGES ON DATABASE temporal_visibility to $DATABASE_URL;" >> init.sql
# Create the database for Airbyte
psql -f init.sql \$DATABASE_URL
echo "Database initialization complete."
EOF
RUN chmod +x init_db.sh
CMD ["./init_db.sh"]