kemonine
/
lollipopcloud
Archived
1
0
Fork 0
This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
lollipopcloud/services/postgres.md

66 lines
1.7 KiB
Markdown
Raw Normal View History

2018-08-16 18:30:16 +00:00
# Postgresql
A database for all those awesome services you'll be running.
## Install / Update / Run Script
2019-01-29 05:55:31 +00:00
Setup a generic script that'll auto update, build a container and launch it. You should only run this script at first launch and/or when you're looking for updates.
If you are running your operating system from a Micro SD Card, You may wish to store your data directory on a [USB drive](../hardware/usb-flash-drive.md) to reduce the number of writes to the SD card. If you do so, don't forget to change the volume mount path when starting the docker container.
2018-08-16 18:30:16 +00:00
``` bash
2019-01-29 05:55:31 +00:00
# Create directory for postgres to store data.
# Alternatively, create a directory on a USB drive
2018-08-16 18:30:16 +00:00
mkdir -p /var/postgres/data
cat > /scratch/docker/postgres.sh << EOF
2018-08-16 18:30:16 +00:00
#!/bin/bash
VERSION=""
ARCH=\`arch\`
2019-01-29 05:55:31 +00:00
# Cleanup arch/container image here.
2018-08-16 18:30:16 +00:00
if [ \$ARCH == "aarch64" ]
then
echo "64bit arm"
VERSION="arm64v8/postgres:latest"
else
echo "32bit arm"
VERSION="arm32v7/postgres:latest"
fi
docker pull \$VERSION
2019-01-29 05:55:31 +00:00
# Cleanup existing container.
2018-08-16 18:30:16 +00:00
docker stop postgres
docker rm postgres
2019-01-29 05:55:31 +00:00
# Re-run/create container with latest image.
# Don't forget to change the volume mount path
# if you changed it above.
#
# Please change user and password below to something
# approrpriate to your installation.
2018-08-16 18:30:16 +00:00
docker run \\
--name postgres \\
--restart unless-stopped \\
--net docker-private \\
--ip 172.30.12.12 \\
-e TZ=UTC \\
-e DEBUG=1 \\
2019-01-29 05:55:31 +00:00
-e POSTGRES_USER=mypostgres
2018-08-16 18:30:16 +00:00
-e POSTGRES_PASSWORD=test1234 \\
-v /var/postgres/data:/var/lib/postgresql/data \\
\$VERSION
EOF
chmod a+x /scratch/docker/postgres.sh
2018-08-16 18:30:16 +00:00
```
## Run Postgres
Simply execute ```/scratch/docker/postgres.sh``` to update/run Postgres.