-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 024c617
Showing
8 changed files
with
109 additions
and
0 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,9 @@ | ||
logs | ||
db | ||
backup | ||
|
||
*.pid | ||
*.pid.lock | ||
*.iml | ||
.idea | ||
|
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,31 @@ | ||
FROM postgres:12 | ||
|
||
LABEL maintainer='Andrey Solovyev [email protected]' | ||
|
||
RUN apt-get update | ||
RUN apt-get -y install postgresql-server-dev-12 libsybdb5 freetds-dev freetds-common make gcc git libaio1 libaio-dev | ||
|
||
WORKDIR /root | ||
|
||
RUN git clone https://github.com/tds-fdw/tds_fdw.git | ||
WORKDIR tds_fdw | ||
RUN make USE_PGXS=1 | ||
RUN make USE_PGXS=1 install | ||
|
||
WORKDIR /root | ||
|
||
RUN apt-get clean && \ | ||
rm -rf /var/cache/apt/* /var/lib/apt/lists/* | ||
|
||
#ENTRYPOINT ["/docker-entrypoint.sh"] | ||
RUN mkdir /pg | ||
RUN mkdir /backup | ||
RUN mkdir /logs | ||
RUN chown postgres:postgres /logs | ||
RUN chown postgres:postgres /pg | ||
RUN chown postgres:postgres /backup | ||
|
||
WORKDIR /pg | ||
|
||
EXPOSE 5432 | ||
#CMD ["postgres"] |
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,3 @@ | ||
WARNING !!!! All additional components and libraries are provided by their vendors free sources 'as is', | ||
and should be used with respect to their licenses. | ||
--- |
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,29 @@ | ||
version: '3.1' | ||
|
||
services: | ||
|
||
postgres: | ||
build: . | ||
restart: always | ||
container_name: "postgres" | ||
volumes: | ||
- ./db:/var/lib/postgresql/data/ # persist data even if container shuts down | ||
- ./logs:/logs | ||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql | ||
- ./backup:/backup | ||
ports: | ||
- 5430:5432 | ||
networks: | ||
- share-network | ||
environment: | ||
POSTGRES_PASSWORD: 1234 | ||
#below is not used and should be set directly. | ||
SQL_SERVER_USER: sqlserv_user | ||
SQL_SERVER_PASSWORD: sqlserv_password | ||
SQL_SERVER_HOST: 192.168.0.32 | ||
SQL_SERVER_PORT: 1433 | ||
SQL_SERVER_DB: db_name | ||
SQL_SERVER_SCHEMA: sql_srv_schema_name | ||
command: postgres -c logging_collector=on -c log_destination=stderr -c log_directory=../logs | ||
networks: | ||
share-network: |
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,28 @@ | ||
-- creating new db user | ||
CREATE ROLE db_admin LOGIN PASSWORD 'db_admin'; | ||
-- creating new db | ||
CREATE DATABASE db_name owner db_admin ENCODING 'UTF8'; | ||
|
||
\c db_name | ||
|
||
CREATE EXTENSION tds_fdw; | ||
-- env vars can not be passed here directly | ||
-- TODO: sh script to init with env vars | ||
CREATE SERVER mssql_svr | ||
FOREIGN DATA WRAPPER tds_fdw | ||
OPTIONS (servername '192.168.0.32', port '1433', database 'db_to_use', tds_version '7.1'); | ||
|
||
GRANT USAGE ON FOREIGN SERVER mssql_svr TO db_admin; | ||
|
||
CREATE USER MAPPING FOR db_admin | ||
SERVER mssql_svr | ||
OPTIONS (username 'sql_srv_username', password 'sql_srv_password'); | ||
|
||
CREATE USER MAPPING FOR postgres | ||
SERVER mssql_svr | ||
OPTIONS (username 'sql_srv_username', password 'sql_srv_password'); | ||
|
||
IMPORT FOREIGN SCHEMA sql_srv_schema_name | ||
FROM SERVER mssql_svr | ||
INTO public | ||
OPTIONS (import_default 'true'); |
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,5 @@ | ||
Postgres 12 with tds_fdw extension to access MSSQL server DB directly using foreign tables. Includes basic commands to create and configure foreign server. | ||
|
||
Created on base of: https://hub.docker.com/r/muritiku/postgres-tds | ||
|
||
See TODO in sql script. You have to manually change SQL server values there. |
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,3 @@ | ||
mkdir db | ||
mkdir logs | ||
docker-compose up --build -d postgres |
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 @@ | ||
docker-compose down |