-
Notifications
You must be signed in to change notification settings - Fork 5
/
rockcraft.yaml
87 lines (86 loc) · 3.49 KB
/
rockcraft.yaml
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
name: charmed-postgresql
base: ubuntu@22.04
version: '14.13'
summary: PostgreSQL in a rock.
description: |
The PostgreSQL rock is created using the
charmed-postgresql-snap and includes all of the
components needed to run PostgreSQL in your Kubernetes
cluster.
license: Apache-2.0
platforms:
amd64:
arm64:
parts:
postgresql-snap:
plugin: nil
stage-snaps:
- charmed-postgresql/14/edge
stage-packages:
- python3
overlay-packages:
- ca-certificates
- tzdata
- logrotate
- libfreetype6
- libjson-c5
- libssh-4
- liblapack3
- libedit2
non-root-user:
plugin: nil
after: [postgresql-snap]
overlay-script: |
# Create a user in the $CRAFT_OVERLAY chroot
groupadd -R $CRAFT_OVERLAY -g 584788 postgres
useradd -R $CRAFT_OVERLAY -M -r -g postgres -u 584788 postgres
override-prime: |
craftctl default
# This is only needed until this bug is resolved with pebble
# https://github.com/canonical/pebble/issues/189
mkdir -p $CRAFT_PRIME/home/postgres
array=( .bash_logout .bashrc .profile )
for i in "${array[@]}"
do
cp /etc/skel/"$i" $CRAFT_PRIME/home/postgres
chown 584788 $CRAFT_PRIME/home/postgres/"$i"
done
chown -R 584788 $CRAFT_PRIME/var/log/pgbackrest
chown -R 584788 $CRAFT_PRIME/var/log/postgresql
chown -R 584788 $CRAFT_PRIME/var/log/prometheus
mkdir -p $CRAFT_PRIME/var/log/pgbouncer
chown -R 584788 $CRAFT_PRIME/var/log/pgbouncer
mkdir -p $CRAFT_PRIME/var/run/postgresql
chown -R 584788 $CRAFT_PRIME/var/run/postgresql
mkdir -p $CRAFT_PRIME/var/lib/pgbouncer
chown -R 584788 $CRAFT_PRIME/var/lib/pgbouncer
# Generate dpkg.query
mkdir -p $CRAFT_PRIME/usr/share/rocks
echo "# os-release" > $CRAFT_PRIME/usr/share/rocks/dpkg.query
cat \
${CRAFT_PROJECT_DIR}/../bundles/ubuntu-22.04/rootfs/etc/os-release \
>> $CRAFT_PRIME/usr/share/rocks/dpkg.query
echo "# dpkg-query" >> $CRAFT_PRIME/usr/share/rocks/dpkg.query
declare -a fields
fields+=('${db:Status-Abbrev}')
fields+=('${binary:Package}')
fields+=('${Version}')
fields+=('${source:Package}')
fields+=('${Source:Version}')
printf -v dpkg_ops '%s,' "${fields[@]}"
dpkg-query -W -f "${dpkg_ops}\n" \
--root=${CRAFT_PROJECT_DIR}/../parts/postgresql-snap/layer/ \
>> $CRAFT_PRIME/usr/share/rocks/dpkg.query
# PostgreSQL extensions
pushd "${CRAFT_PRIME}/usr/share/postgresql/14/extension"
ln -f postgis-3.control postgis.control
ln -f address_standardizer-3.control \
address_standardizer.control
ln -f address_standardizer_data_us-3.control \
address_standardizer_data_us.control
ln -f postgis_raster-3.control postgis_raster.control
ln -f postgis_tiger_geocoder-3.control \
postgis_tiger_geocoder.control
ln -f postgis_topology-3.control postgis_topology.control
ln -f postgis_topology-3.control postgis_topology.control
popd