forked from neondatabase/autoscaling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image-spec.yaml
127 lines (110 loc) · 3.85 KB
/
image-spec.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
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
121
122
123
124
125
126
127
# Input to vm-builder
---
commands:
- name: cgconfigparser
user: root
sysvInitAction: sysinit
shell: '/usr/sbin/cgconfigparser -l /etc/cgconfig.conf -s 1664'
- name: postgres-data
user: root
sysvInitAction: sysinit
shell: 'mkdir -p /run/postgresql && chown -R postgres:postgres /run/postgresql'
- name: vm-monitor
user: vm-monitor
sysvInitAction: respawn
shell: 'RUST_LOG=info /bin/vm-monitor --cgroup=neon-test --addr="0.0.0.0:10301"'
- name: start-postgres
user: postgres
sysvInitAction: once
shell: 'PGDATA=/var/lib/postgresql pg_ctl start -o "-c config_file=/etc/postgresql.conf -c hba_file=/etc/pg_hba.conf" -l /dev/virtio-ports/tech.neon.log.0'
files:
- filename: postgresql.conf
hostPath: postgresql.conf
- filename: pg_hba.conf
hostPath: pg_hba.conf
- filename: allocate-loop.c
hostPath: allocate-loop.c
- filename: cgconfig.conf
hostPath: cgconfig.conf
build: |
# Build vm-monitor
FROM rust:1.74-alpine as monitor-builder
WORKDIR /workspace
RUN apk add musl-dev git openssl-dev
# Which branch to pull from
ENV BRANCH main
# Ensures we reclone upon new commits
# https://stackoverflow.com/questions/35134713
ADD "https://api.github.com/repos/neondatabase/neon/commits/$BRANCH" latest_commit
RUN git clone --depth 1 --branch $BRANCH https://github.com/neondatabase/neon.git
RUN cargo build --release --manifest-path neon/libs/vm_monitor/Cargo.toml
# Move binary so we can cargo clean
RUN mkdir -p /workspace/bin && cp /workspace/neon/target/release/vm-monitor /workspace/bin
# Cargo clean dramatically reduces the size of the image
RUN cargo clean --release --manifest-path neon/libs/vm_monitor/Cargo.toml
# Build PostgreSQL
FROM alpine:3.19 AS pg-builder
# PostgreSQL build dependencies
RUN set -e \
&& apk add --no-cache \
build-base \
git \
openssl-dev \
perl \
perl-dev \
bison \
flex \
zlib-dev \
readline-dev \
libxml2-dev \
libxslt-dev \
linux-headers \
icu-libs \
icu-dev \
make
# Clone PostgreSQL repository
RUN set -e \
&& git clone https://github.com/IvorySQL/IvorySQL.git /usr/src/ivorysql && \
cd /usr/src/ivorysql && \
git checkout tags/IvorySQL_3.2
# Set the working directory
WORKDIR /usr/src/ivorysql
RUN ./configure && make && make install
# Build the allocation tester:
FROM alpine:3.19 AS allocate-loop-builder
RUN set -e \
&& apk add gcc musl-dev
COPY allocate-loop.c allocate-loop.c
RUN set -e \
&& gcc -g -O allocate-loop.c -o /bin/allocate-loop
merge: |
RUN adduser vm-monitor --disabled-password --no-create-home
COPY cgconfig.conf /etc/cgconfig.conf
COPY postgresql.conf /etc/postgresql.conf
COPY pg_hba.conf /etc/pg_hba.conf
# General tools
RUN set -e \
&& apk add --no-cache \
ca-certificates \
util-linux-misc \
coreutils \
cgroup-tools
# postgresql stuff
RUN set -e \
&& apk add --no-cache \
su-exec \
icu-libs \
readline
# Create the "postgres" user
RUN adduser -D -H -u 70 -s /bin/sh postgres
COPY --from=pg-builder /usr/local/pgsql /usr/
# Initialize postgres
ENV PGDATA /var/lib/postgresql
RUN set -e \
&& mkdir -p ${PGDATA} /run/postgresql \
&& chown -R postgres:postgres ${PGDATA} /run/postgresql \
&& su-exec postgres pg_ctl init
COPY --from=allocate-loop-builder /bin/allocate-loop /bin/allocate-loop
COPY --from=monitor-builder /workspace/bin/vm-monitor /bin/vm-monitor
# set the greeting message on ssh logins
RUN echo -e 'Welcome to Alpine!\n ~ This is the VM IVY3.0:) ~' >/etc/motd