Skip to content

Commit b0309d2

Browse files
committed
Initial commit
1 parent da30b44 commit b0309d2

5 files changed

Lines changed: 67 additions & 42 deletions

File tree

.github/workflows/main.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Extract version from tag
18+
id: get_version
19+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
20+
21+
- name: Login to Docker Hub
22+
uses: docker/login-action@v3
23+
with:
24+
username: ${{ secrets.DOCKERHUB_USERNAME }}
25+
password: ${{ secrets.DOCKERHUB_TOKEN }}
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
with:
30+
install: true
31+
32+
- name: Create Docker Buildx builder
33+
run: docker buildx create --use --name mybuilder
34+
35+
- name: Build and push image
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: .
39+
push: true
40+
tags: |
41+
${{ secrets.DOCKERHUB_USERNAME }}/postgres:latest
42+
${{ secrets.DOCKERHUB_USERNAME }}/postgres:${{ env.VERSION }}
43+
platforms: linux/amd64

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ ENV PGDATA_TS=/var/lib/postgresql/ts/data
1111
VOLUME ["/var/lib/postgresql/data"]
1212
VOLUME ["/var/lib/postgresql/ts"]
1313

14-
ADD --chmod=755 scripts/004_obmp_psql_cfg.sh /docker-entrypoint-initdb.d/004_obmp_psql_cfg.sh
15-
ADD --chmod=755 scripts/005_obmp_init.sh /docker-entrypoint-initdb.d/005_obmp_init.sh
14+
ADD --chmod=755 scripts/001_configuration.sh /docker-entrypoint-initdb.d/001_configuration.sh
15+
ADD --chmod=755 scripts/002_initialization.sh /docker-entrypoint-initdb.d/002_initialization.sh
1616

1717
USER root
1818

1919
RUN rm -rf /usr/lib/postgresql/12 /usr/lib/postgresql/13 \
2020
&& mkdir -p /var/lib/postgresql/data /var/lib/postgresql/ts/data \
2121
&& chown -R postgres /var/lib/postgresql/data /var/lib/postgresql/ts/data \
22-
&& mkdir -p /usr/local/openbmp \
23-
&& touch /usr/local/openbmp/version-${VERSION}
2422

2523
USER postgres

README.md

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
# OpenBMP Postgres
1+
# Postgres
22
The postgres container is a plain postgres/timescaleDB container with
3-
some modifications to support OpenBMP. Any postgres install will work as long as
4-
they have similar changes as shown in [Dockerfile](Dockerfile).
3+
some modifications to support our application.
54

65
## Building
76
See the [Dockerfile](Dockerfile) notes for build instructions.
87

9-
## Running
8+
## Getting Started
109
```
1110
docker run --rm -it -p 5432:5432 \
12-
-e POSTGRES_PASSWORD=openbmp \
13-
-e POSTGRES_USER=openbmp \
14-
-e POSTGRES_DB=openbmp \
15-
openbmp/postgres:<version>
11+
-e POSTGRES_PASSWORD=bgpdata \
12+
-e POSTGRES_USER=bgpdata \
13+
-e POSTGRES_DB=bgpdata \
14+
bgpdata/postgres:<version>
1615
```
1716

18-
### Configuration/Environment Variables
19-
See both [Postgres](https://hub.docker.com/_/postgres) and
20-
[TimescaleDB](https://hub.docker.com/r/timescale/timescaledb) documentation for more
21-
information on how to configure/run the docker container.
22-
23-
### PostgreSQL Related
17+
### Additional Information
2418

2519
#### Postgres can be killed by the Linux OOM-Killer
2620
This is very bad as it causes Postgres to restart. This will happen because postgres uses a large shared buffer,
@@ -52,38 +46,36 @@ then try the below:
5246
echo never > /sys/kernel/mm/transparent_hugepage/defrag
5347
sync && echo 3 > /proc/sys/vm/drop_caches
5448

55-
56-
#### Postgres Vacuum (reclaim disk space)
49+
#### Postgres Vacuum (Reclaim Disk Space)
5750
Postgres reclaims deleted/updated records using the vacuum process. You can run this manually/cron via the
5851
```VACUUM``` command. **autovacuum** is used to do this periodically. Careful tuning of this
5952
is required. Checkout [autovacuum-tuning-basics](https://blog.2ndquadrant.com/autovacuum-tuning-basics/),
6053
[Routine Vacuuming](https://www.postgresql.org/docs/current/static/routine-vacuuming.html), and
6154
[VACUUM](https://www.postgresql.org/docs/current/static/sql-vacuum.html) for more details.
6255

63-
#### Create persistent postgres locations
56+
#### Persistent Postgres locations
6457

6558
*You should use fast SSD and/or ZFS.* Size of these locations/mount points are directly related to the
6659
number of NLRI's maintained and number of changes/updates per second.
6760

68-
> TODO: Will post numbers of how to determine the disk size needed. For now, if you have less
69-
> than 50,000,00 prefixes, then you can use 1TB. If you have more than that, you should consider
70-
> multiple disks. ZFS can make your life easier as you can easily add disks and it supports compression.
61+
> NOTE: If you have less than 50,000,00 prefixes, then you can use 1TB. If you have more than that, please consider
62+
> multiple disks. ZFS can make our life easier as you can easily add disks and it supports compression.
7163
7264
- **postgres/main** - This location will be used for the main postgres data
7365
files and tables.
7466

7567
> This really should be a mount point to a dedicated filesystem
7668
7769
```
78-
mkdir -p /var/openbmp/postgres/main
79-
chmod 7777 /var/openbmp/postgres/main
70+
mkdir -p /var/bgpdata/postgres/main
71+
chmod 7777 /var/bgpdata/postgres/main
8072
```
8173

8274
- **postgres/ts** - This location will be used for the time series postgres tables
8375

8476
> This really should be a mount point to a dedicated filesystem
8577
8678
```
87-
mkdir -p /var/openbmp/postgres/ts
88-
chmod 7777 /var/openbmp/postgres/ts
79+
mkdir -p /var/bgpdata/postgres/ts
80+
chmod 7777 /var/bgpdata/postgres/ts
8981
```
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/bin/bash
2-
3-
# OpenBMP Postgres configuration
4-
#
5-
# Copyright (c) 2022 Cisco Systems, Inc. and Tim Evens. All rights reserved.
6-
#
7-
2+
# Copyright (c) 2021-2022 Cisco Systems, Inc. and others.
3+
# All rights reserved.
84

95
# Create SSL cert
106
openssl req -x509 -newkey rsa:4096 -nodes -subj "/C=US/ST=CA/L=Seattle/O=OpenBMP/CN=localhost" \
@@ -23,12 +19,11 @@ sed -i -e "s/^\#*ssl_key_file.*=.*/ssl_key_file = '${PGDATA//\//\\\/}\/psql_ser
2319

2420
sed -i -e "s/^shared_preload_libraries.*/shared_preload_libraries = 'timescaledb,pg_cron'/g" $PGDATA/postgresql.conf
2521

26-
echo "cron.database_name = 'openbmp'" >> $PGDATA/postgresql.conf
22+
echo "cron.database_name = '$POSTGRES_DB'" >> $PGDATA/postgresql.conf
2723

2824
egrep -q -e '^hostssl( |\t)+all' $PGDATA/pg_hba.conf
2925
if [[ $? ]]; then
3026
echo 'hostssl all all 0.0.0.0/0 md5' >> $PGDATA/pg_hba.conf
3127
fi
3228

33-
3429
pg_ctl -D "$PGDATA" -m fast -w restart
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#!/bin/bash
2+
# Copyright (c) 2021-2022 Cisco Systems, Inc. and others.
3+
# All rights reserved.
24

3-
# postgres: Init script
4-
#
5-
# Copyright (c) 2021-2022 Cisco Systems, Inc. and Tim Evens. All rights reserved.
6-
#
7-
8-
# >> NOTE, before adding extensions, required preload/config should be done first in 004_obmp_psql_cfg.sh
5+
# Required: Execute 004_obmp_psql_cfg.sh for preload configuration before adding extensions
96

107
# Add extensions
118
psql -U $POSTGRES_USER -c "CREATE EXTENSION IF NOT EXISTS postgis CASCADE;" $POSTGRES_DB

0 commit comments

Comments
 (0)