-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
156 lines (131 loc) · 4.29 KB
/
Dockerfile
File metadata and controls
156 lines (131 loc) · 4.29 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# -------------------------
# Djazz-Services Dockerfile
# https://djazz.cc
# Author: @azataiot
# Date: 2024-05-27
# ----------------
ARG VERSION=0.1.0
ARG BASE_IMAGE=azataiot/alpine:latest
FROM ${BASE_IMAGE} as builder
ENV LANG en_US.utf8
ENV VERSION=${VERSION}
# Update and upgrade the system
RUN set -eux; \
apk update; \
apk upgrade; \
echo "Building ${VERSION}"
# ---------------
# Mailpit Builder
# ---------------
RUN set -eux; \
apk add --no-cache \
curl; \
MP_VERSION=$(curl --silent --location --max-time "90" "https://api.github.com/repos/axllent/mailpit/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'); \
BUILDOS=$(uname -s | tr '[:upper:]' '[:lower:]'); \
BUILDARCH=$(uname -m); \
if [ "$BUILDARCH" = "aarch64" ]; then \
BUILDARCH="arm64"; \
elif [ "$BUILDARCH" = "x86_64" ]; then \
BUILDARCH="amd64"; \
fi; \
MP_GO_BIN="mailpit-${BUILDOS}-${BUILDARCH}.tar.gz"; \
echo "Downloading Mailpit ${MP_VERSION} for ${BUILDOS}-${BUILDARCH}"; \
mkdir -p /tmp/mailpit; \
wget -O /tmp/mailpit/${MP_GO_BIN} https://github.com/axllent/mailpit/releases/download/${MP_VERSION}/${MP_GO_BIN}; \
tar -xzf /tmp/mailpit/${MP_GO_BIN} -C /tmp/mailpit; \
mv /tmp/mailpit/mailpit /usr/local/bin/mailpit; \
chmod +x /usr/local/bin/mailpit; \
rm -rf /tmp/mailpit
# ----------------
# RabbitMQ Builder
# ----------------
RUN set -eux; \
apk add --no-cache \
erlang
# Download "Generic Binary Build" of RabbitMQ server
RUN set -eux; \
\
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.13.2/rabbitmq-server-generic-unix-3.13.2.tar.xz; \
tar -xf rabbitmq-server-generic-unix-3.13.2.tar.xz; \
mv rabbitmq_server-3.13.2 /opt/rabbitmq; \
ls -la /opt/rabbitmq; \
rm rabbitmq-server-generic-unix-3.13.2.tar.xz; \
echo 'export PATH=/opt/rabbitmq/sbin:$PATH' >> ~/.bashrc ; \
echo "loopback_users.guest = false" >> /opt/rabbitmq/etc/rabbitmq/rabbitmq.conf; \
echo "log.console = true" >> /opt/rabbitmq/etc/rabbitmq/rabbitmq.conf ; \
echo "log.console.level = warning" >> /opt/rabbitmq/etc/rabbitmq/rabbitmq.conf ; \
/opt/rabbitmq/sbin/rabbitmq-plugins enable rabbitmq_management
FROM ${BASE_IMAGE} as final
ENV LANG en_US.utf8
ENV VERSION=${VERSION}
# Add packages
RUN echo "Building ${VERSION}"
RUN set -eux; \
apk add --no-cache \
ncurses \
postgresql \
postgresql-contrib \
redis \
minio \
erlang \
supervisor ;\
mkdir -p /etc/supervisor.d ;\
mkdir -p /opt/djazz/supervisor.d
# -------
# Mailpit
# -------
ENV MAILPIT_USER=mailpit
ENV MAILPIT_PASSWORD=mailpit
COPY --from=builder /usr/local/bin/mailpit /usr/local/bin/mailpit
EXPOSE 8025
EXPOSE 1025
# -----
# Minio
# -----
ENV MINIO_ROOT_USER=minio
ENV MINIO_ROOT_PASSWORD=minio123
EXPOSE 9000 9001
VOLUME /var/lib/minio/data
# --------
# Postgres
# --------
ENV PGDATA=/var/lib/postgresql/data
ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=postgres
ENV POSTGRES_DB=postgres
ENV TZ=UTC
RUN set -eux; \
\
mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 700 "$PGDATA"; \
mkdir -p /run/postgresql && chown -R postgres:postgres /run/postgresql && chmod 3777 /var/run/postgresql ; \
echo "$POSTGRES_PASSWORD" > /tmp/pgpass
EXPOSE 5432
VOLUME /var/lib/postgresql/data
# --------
# RabbitMQ
# --------
COPY --from=builder /root/.bashrc /root/.bashrc
COPY --from=builder /opt/rabbitmq/escript /opt/rabbitmq/escript
COPY --from=builder /opt/rabbitmq/etc /opt/rabbitmq/etc
COPY --from=builder /opt/rabbitmq/plugins /opt/rabbitmq/plugins
COPY --from=builder /opt/rabbitmq/sbin /opt/rabbitmq/sbin
COPY --from=builder /opt/rabbitmq/share /opt/rabbitmq/share
EXPOSE 5672 15672
VOLUME /opt/rabbitmq/var
# -----
# Redis
# -----
ENV REDIS_PASSWORD=redis
EXPOSE 6379
VOLUME /etc/redis/
# Copy the docker-entrypoint.sh script into the Docker image
COPY ./scripts/entrypoint.sh /usr/local/bin/
COPY ./scripts/common.sh /usr/local/bin/
COPY ./scripts/logger.sh /usr/local/bin/logger
COPY ./scripts/supervisord.conf /etc/supervisord.conf
COPY ./scripts/supervisor.d/* /opt/djazz/supervisor.d/
# Make the script executable
RUN chmod +x /usr/local/bin/entrypoint.sh
# Use the script as the entrypoint
ENTRYPOINT ["entrypoint.sh"]
CMD ["all"]