11# vim:set ft=dockerfile:
2- FROM alpine:3.17
2+
3+ # We grab RabbitMQ and Erlang from the official RabbitMQ image
4+ FROM rabbitmq:3-alpine AS rabbit
5+
6+ # Build our own image
7+ FROM alpine:3.18
38
49LABEL maintainer="Justin Clift <justin@postgresql.org>"
510
6- # Install Git, Go, Memcached, Minio, OpenRC, PostgreSQL, and RabbitMQ
7- RUN \
8- apk update && \
11+ # Copy the RabbitMQ files we need
12+ COPY --from=rabbit /etc/rabbitmq /etc/rabbitmq
13+ COPY --from=rabbit /opt/erlang /opt/erlang
14+ COPY --from=rabbit /opt/openssl /opt/openssl
15+ COPY --from=rabbit /opt/rabbitmq /opt/rabbitmq
16+ COPY --from=rabbit /var/lib/rabbitmq /var/lib/rabbitmq
17+ COPY --from=rabbit /var/log/rabbitmq /var/log/rabbitmq
18+
19+ # Create the rabbitmq user and group
20+ RUN addgroup -S rabbitmq && \
21+ adduser -S -D -h /var/lib/rabbitmq -s /sbin/nologin -g "Linux User,,," -G rabbitmq rabbitmq && \
22+ chown -Rh rabbitmq: /opt/rabbitmq /var/log/rabbitmq
23+
24+ # Install Git, Go, Memcached, Minio, OpenRC, and PostgreSQL
25+ RUN apk update && \
926 apk upgrade && \
1027 apk add --no-cache ca-certificates 'curl>7.61.0' file git go libc-dev make memcached minio openrc openssl openssl-dev postgresql yarn && \
11- apk add rabbitmq-server --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ && \
1228 rc-update add memcached default && \
1329 rc-update add minio default && \
14- rc-update add postgresql default && \
15- rc-update add rabbitmq-server default && \
16- mkdir /etc/rabbitmq && \
17- rabbitmq-plugins enable rabbitmq_management && \
18- rabbitmq-plugins enable rabbitmq_top
30+ rc-update add postgresql
1931
2032# Create the DBHub.io OS user
2133RUN addgroup dbhub && \
@@ -31,7 +43,7 @@ ENV MINIO_ROOT_PASSWORD minio123
3143RUN sed -i "s/^MINIO_ROOT_USER=\" change-me\" /MINIO_ROOT_USER=\" ${MINIO_ROOT_USER}\" /" /etc/conf.d/minio && \
3244 sed -i "s/^MINIO_ROOT_PASSWORD=\" change-me\" /MINIO_ROOT_PASSWORD=\" ${MINIO_ROOT_PASSWORD}\" /" /etc/conf.d/minio
3345
34- # Run each of our daemon dependencies at least once to ensure they initialise ok, and populate the DBHub.io database
46+ # Run each of our (non RabbitMQ) daemon dependencies at least once to ensure they initialise ok, and populate the DBHub.io database
3547RUN echo "openrc nonetwork" >> /usr/local/bin/init.sh && \
3648 echo "openrc default stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
3749 echo "createuser -U postgres -d dbhub" >> /usr/local/bin/init.sh && \
@@ -40,7 +52,6 @@ RUN echo "openrc nonetwork" >> /usr/local/bin/init.sh && \
4052 echo "rc-service memcached stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
4153 echo "rc-service minio stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
4254 echo "rc-service postgresql stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
43- echo "rc-service rabbitmq-server stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
4455 chmod +x /usr/local/bin/init.sh
4556
4657# Set the dependencies and DBHub.io daemons to automatically start
@@ -62,6 +73,11 @@ RUN GOBIN=/usr/local/bin go install github.com/go-delve/delve/cmd/dlv@latest
6273RUN echo "echo 127.0.0.1 docker-dev.dbhub.io docker-dev >> /etc/hosts" >> /usr/local/bin/start.sh && \
6374 echo "openrc default" >> /usr/local/bin/start.sh && \
6475 echo "" >> /usr/local/bin/start.sh && \
76+ echo "unset CONFIG_FILE" >> /usr/local/bin/start.sh && \
77+ echo "export RABBITMQ_CONFIG_FILES=/etc/rabbitmq/conf.d" >> /usr/local/bin/start.sh && \
78+ echo "export PATH=/opt/rabbitmq/sbin:/opt/erlang/bin:/opt/openssl/bin:$PATH" >> /usr/local/bin/start.sh && \
79+ echo "/opt/rabbitmq/sbin/rabbitmq-server &" >> /usr/local/bin/start.sh && \
80+ echo "" >> /usr/local/bin/start.sh && \
6581 echo "# Wait for RabbitMQ to start before launching the DBHub.io daemons" >> /usr/local/bin/start.sh && \
6682 echo "sleep 15" >> /usr/local/bin/start.sh && \
6783 echo "" >> /usr/local/bin/start.sh && \
0 commit comments