Skip to content

Commit

Permalink
Added tds listen_addresses and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
3manuek committed Nov 17, 2021
1 parent b0b7249 commit 3700202
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Dockerfile.ubuntu-focal
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ RUN useradd postgres && usermod -a -G postgres postgres
RUN set -eux; \
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \
sed -ri "s+#?shared_preload_libraries.*+shared_preload_libraries = 'babelfishpg_tds'+g" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \
sed -i -e "\$ababelfishpg_tds.listen_addresses = '*'" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \
grep -F "listen_addresses = '*'" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \
grep -F "shared_preload_libraries = 'babelfishpg_tds'" "${PREFIX}/share/postgresql/postgresql.conf.sample";
grep -F "shared_preload_libraries = 'babelfishpg_tds'" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \
grep -F "babelfishpg_tds.listen_addresses = '*'" "${PREFIX}/share/postgresql/postgresql.conf.sample";

RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA"

Expand Down
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,55 @@ Docker environments for Babelfish test.
docker pull registry.gitlab.com/ongresinc/labs/babelfish-on-docker:latest
```

Or, use compose:
```
docker-compose -f docker-compose-remote.yml up
```

Access through local:

```bash
docker-compose build babelfishpg-ubuntu-focal
docker-compose up
docker-compose exec babelfishpg-ubuntu-focal bash -c 'sqlcmd -H localhost:1433 -P password -U bbf'
```

See that you can add more distros in the same compose, and build by build argument as above.
To access through host mode in the same machine, it can be issued a similar command to the below (you may need to change the network name entry):

```bash
DOCKER_BBF_IP=$(docker inspect -f "{{with index .NetworkSettings.Networks \"babelfish-on-docker_babelfish\"}}{{.IPAddress}}{{end}}" babelfishpg-ubuntu-focal)
```

Access:
Then, you can either use your psql or your MSSQL Server client of preference ([FreeTDS](https://www.freetds.org/) in the following example):

```bash
docker-compose exec babelfishpg-ubuntu-focal bash -c 'sqlcmd -H localhost:1433 -P password -U bbf'
/opt/babelfish/bin/psql -h ${DOCKER_BBF_IP} -p 5432 -U bbf bbf
tsql -S ${DOCKER_BBF_IP} -p 1433 -U bbf bbf
```

> BABELFISH_DB is the Postgres database that has the Babelfish extensions, and it is called `master` in SQL Server. So, certain clients like DBeaver will need to specify the master instead of the Postgres name.
## Build dev
## Multi-DB / Single-DB

The current image uses multi-db as the default migration mode. It means that all the databases you create in the Babelfish database (through TDS), will be reflected as Postgres _schemas_ in the selected Babelfish database.

The mapped schemas will had the `*-dbo` suffix. This mode is useful if you rely on multi schema login against your SQL Server.

Single-DB will allow only one user database, and it might be the most recommended mode for beginners.


## Building

```bash
docker-compose build babelfishpg-ubuntu-focal
docker-compose up

```
docker tag babelfishpg:ubuntu.focal registry.gitlab.com/ongresinc/labs/babelfish-on-docker
docker tag babelfishpg:ubuntu.focal ghcr.io/ongres/babelfish-on-docker-compose
docker push registry.gitlab.com/ongresinc/labs/babelfish-on-docker
docker push ghcr.io/ongres/babelfish-on-docker-compose
```

See that you can add more distros in the same compose, and build by build argument as above.



## References

Expand Down
3 changes: 3 additions & 0 deletions docker-compose-remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ version: "3"

services:
babelfishpg:
container_name: babelfishpg-ubuntu-focal
image: registry.gitlab.com/ongresinc/labs/babelfish-on-docker
ports:
- 1433:10433
- 5432:15432
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- BABELFISH_USER=bbf
- BABELFISH_PASS=password
- BABELFISH_DB=bbf
- BABELFISH_MIGRATION_MODE=multi-db
- POSTGRES_HOST_AUTH_METHOD=trust
networks:
- babelfish
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: "3"

services:
babelfishpg-ubuntu-focal:
container_name: babelfishpg-ubuntu-focal
build:
context: .
dockerfile: Dockerfile.ubuntu-focal
Expand All @@ -10,14 +11,16 @@ services:
MAX_JOBS: 4
image: babelfishpg:ubuntu.focal
ports:
- 1433:10433
- 1433:1433
- 5432:15432
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- BABELFISH_USER=bbf
- BABELFISH_PASS=password
- BABELFISH_DB=bbf
- BABELFISH_MIGRATION_MODE=multi-db
- POSTGRES_HOST_AUTH_METHOD=trust
networks:
- babelfish
Expand Down
1 change: 1 addition & 0 deletions entrypoint-ubuntu-focal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ docker_setup_env() {
file_env 'POSTGRES_USER' 'postgres'
file_env 'POSTGRES_DB' "$POSTGRES_USER"
file_env 'BABELFISH_MIGRATION_MODE' 'single-db'
file_env 'BABELFISH_MIGRATION_MODE' "$BABELFISH_MIGRATION_MODE"
file_env 'POSTGRES_INITDB_ARGS'
: "${POSTGRES_HOST_AUTH_METHOD:=}"

Expand Down

0 comments on commit 3700202

Please sign in to comment.