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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
# TDS Foreign data wrapper
* **Author:** TheRevenantStar
* **EditedBy:** Guriy Samarin
* **Name:** tds_fdw
* **File:** tds_fdw/InstallAlpine.md
## Installing on Alpine Linux
This document will show how to install tds_fdw on Alpine Linux 3.10.3. Other Alpine Linux distributions should be similar.
### Install FreeTDS and build dependencies
The TDS foreign data wrapper requires a library that implements the DB-Library interface,
such as [FreeTDS](http://www.freetds.org).
```bash
apk add --update freetds-dev
```
Some other dependencies are also needed to install PostgreSQL and then compile tds_fdw:
```bash
apk add gcc libc-dev make
```
In case you will get `fatal error: stdio.h: No such file or directory` later on (on `make USE_PGXS=1`) - installing `musl-dev` migth help (https://stackoverflow.com/questions/42366739/gcc-cant-find-stdio-h-in-alpine-linux):
```bash
apk add musl-dev
```
### Install PostgreSQL
If you need to install PostgreSQL, do so by installing from APK. For example, to install PostgreSQL 11.6 on Alpine Linux:
```bash
apk add postgresql=11.6-r0 postgresql-client=11.6-r0 postgresql-dev=11.6-r0
```
In postgres-alpine docker image you will need only
```bash
apk add postgresql-dev
```
### Install tds_fdw
#### Build from release package
If you'd like to use one of the release packages, you can download and install them via something like the following:
```bash
export TDS_FDW_VERSION="2.0.5"
apk add wget
wget https://github.com/tds-fdw/tds_fdw/archive/v${TDS_FDW_VERSION}.tar.gz
tar -xvzf v${TDS_FDW_VERSION}.tar.gz
cd tds_fdw-${TDS_FDW_VERSION}/
make USE_PGXS=1
sudo make USE_PGXS=1 install
```
**NOTE:** If you have several PostgreSQL versions and you do not want to build for the default one, first locate where the binary for `pg_config` is, take note of the full path, and then append `PG_CONFIG=<PATH>` after `USE_PGXS=1` at the `make` commands.
#### Build from repository
If you would rather use the current development version, you can clone and build the git repository via something like the following:
```bash
apk add git
git clone https://github.com/tds-fdw/tds_fdw.git
cd tds_fdw
make USE_PGXS=1
make USE_PGXS=1 install
```
**NOTE:** If you have several PostgreSQL versions and you do not want to build for the default one, first locate where the binary for `pg_config` is, take note of the full path, and then append `PG_CONFIG=<PATH>` after `USE_PGXS=1` at the `make` commands.
#### Start server
If this is a fresh installation, then create the initial cluster and start the server:
```bash
mkdir /var/lib/postgresql/data
chmod 0700 /var/lib/postgresql/data
chown postgres. /var/lib/postgresql/data
su postgres -c 'initdb /var/lib/postgresql/data'
mkdir /run/postgresql/
chown postgres. /run/postgresql/
su postgres -c 'pg_ctl start -D /var/lib/postgresql/data "-o -c listen_addresses=\"\""'
```
#### Install extension
```bash
psql -U postgres
postgres=# CREATE EXTENSION tds_fdw;
```
#### Dockerfile Example
This Dockerfile will build PostgreSQL 11 in Alpine Linux with tds_fdw from master branch
```
FROM library/postgres:11-alpine
RUN apk add --update freetds-dev && \
apk add git gcc libc-dev make && \
apk add postgresql-dev postgresql-contrib && \
git clone https://github.com/tds-fdw/tds_fdw.git && \
cd tds_fdw && \
make USE_PGXS=1 && \
make USE_PGXS=1 install && \
apk del git gcc libc-dev make && \
cd .. && \
rm -rf tds_fdw
```
You can easily adapt the Dockerfile if you want to use a release package.
This Dockerfile works just like to official PostgreSQL image, just with tds_fdw added. See [Docker Hub library/postgres](https://hub.docker.com/_/postgres/) for details.
|