mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
refactor: new dev/prod containers
- Use a single Dockerfile for all Zeppelin services - Add a Dockerfile in project root that can be used by app hosting services - Provide a standalone and lightweight prod setup - Standalone is the same as the old setup, with mysql+nginx - Lightweight only runs bot+backend+dash, no mysql/nginx - Remove mounted mysql data folders for dev and prod - This resolves permission issues caused by the mount - The mysql service uses a regular named volume now - Simplify .env options and clearly separate different prod setups - Remove update.sh - Different setups require different update procedures, so a common update.sh no longer works
This commit is contained in:
parent
730b8c1d6b
commit
509d96ce83
30 changed files with 948 additions and 274 deletions
|
@ -1,7 +1,7 @@
|
|||
FROM ubuntu:20.04
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ARG DOCKER_DEV_UID
|
||||
ARG DOCKER_DEV_SSH_PASSWORD
|
||||
ARG DEVELOPMENT_UID
|
||||
ARG DEVELOPMENT_SSH_PASSWORD
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=UTC
|
||||
|
@ -15,15 +15,11 @@ RUN add-apt-repository ppa:git-core/ppa && apt-get update && apt-get install -y
|
|||
# Set up SSH access
|
||||
RUN apt-get install -y openssh-server iptables
|
||||
RUN mkdir /var/run/sshd
|
||||
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u $DOCKER_DEV_UID ubuntu
|
||||
RUN echo "ubuntu:${DOCKER_DEV_SSH_PASSWORD}" | chpasswd
|
||||
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u $DEVELOPMENT_UID ubuntu
|
||||
RUN echo "ubuntu:${DEVELOPMENT_SSH_PASSWORD}" | chpasswd
|
||||
|
||||
# Set up proper permissions for volumes
|
||||
RUN mkdir -p /home/ubuntu/zeppelin /home/ubuntu/.vscode-remote /home/ubuntu/.vscode-server /home/ubuntu/.cache/JetBrains
|
||||
RUN chown -R ubuntu /home/ubuntu
|
||||
|
||||
# Install Node.js 18 and packages needed to build native packages
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
|
||||
# Install Node.js 20 and packages needed to build native packages
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||
RUN apt-get install -y nodejs gcc g++ make python3
|
||||
|
||||
CMD ["/usr/sbin/sshd", "-D", "-e"]
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
FROM nginx
|
||||
|
||||
ARG API_PORT
|
||||
ARG DOCKER_DEV_API_PORT
|
||||
ARG DOCKER_DEV_DASHBOARD_PORT
|
||||
|
||||
RUN apt-get update && apt-get install -y openssl
|
||||
RUN openssl req -x509 -newkey rsa:4096 -keyout /etc/ssl/private/localhost-cert.key -out /etc/ssl/certs/localhost-cert.pem -days 3650 -subj '/CN=localhost' -nodes
|
||||
|
||||
COPY ./default.conf /etc/nginx/conf.d/default.conf
|
||||
RUN sed -ir "s/_API_PORT_/${API_PORT}/g" /etc/nginx/conf.d/default.conf
|
||||
|
|
|
@ -3,24 +3,22 @@ server {
|
|||
listen [::]:443 ssl http2;
|
||||
server_name localhost;
|
||||
|
||||
root /zeppelin/dashboard/dist;
|
||||
# Using a variable here stops nginx from crashing if the dev container is restarted or becomes otherwise unavailable
|
||||
set $backend_upstream "http://devenv:3001";
|
||||
set $dashboard_upstream "http://devenv:3002";
|
||||
|
||||
location / {
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
# Using a variable in proxy_pass also requires resolver to be set.
|
||||
# This is the address of the internal docker compose DNS server.
|
||||
resolver 127.0.0.11;
|
||||
proxy_pass $dashboard_upstream$uri$is_args$args;
|
||||
}
|
||||
|
||||
# Using a variable here stops nginx from crashing if the dev container is restarted or becomes otherwise unavailable
|
||||
set $backend_upstream "http://devenv:_API_PORT_";
|
||||
|
||||
location /api {
|
||||
# Remove /api/ from the beginning when passing the path to the API process
|
||||
rewrite /api(/.*)$ $1 break;
|
||||
|
||||
# Using a variable in proxy_pass also requires resolver to be set.
|
||||
# This is the address of the internal docker compose DNS server.
|
||||
resolver 127.0.0.11;
|
||||
|
||||
proxy_pass $backend_upstream$uri$is_args$args;
|
||||
proxy_redirect off;
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
FROM node:18
|
||||
USER node
|
||||
|
||||
COPY --chown=node:node . /zeppelin
|
||||
|
||||
WORKDIR /zeppelin/backend
|
||||
RUN npm ci && npm run build
|
|
@ -1,2 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
2
docker/production/data/mysql/.gitignore
vendored
2
docker/production/data/mysql/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -1,23 +1,9 @@
|
|||
FROM node:18 AS builder
|
||||
USER node
|
||||
|
||||
COPY --chown=node:node . /zeppelin
|
||||
|
||||
WORKDIR /zeppelin/dashboard
|
||||
RUN ls -lah
|
||||
RUN pwd
|
||||
RUN npm ci && npm run build
|
||||
|
||||
FROM nginx
|
||||
|
||||
ARG API_PORT
|
||||
ARG DOCKER_PROD_DOMAIN
|
||||
ARG STANDALONE_DOMAIN
|
||||
|
||||
RUN apt-get update && apt-get install -y openssl
|
||||
RUN openssl req -x509 -newkey rsa:4096 -keyout /etc/ssl/private/zeppelin-self-signed-cert.key -out /etc/ssl/certs/zeppelin-self-signed-cert.pem -days 3650 -subj "/CN=${DOCKER_PROD_DOMAIN}" -nodes
|
||||
RUN openssl req -x509 -newkey rsa:4096 -keyout /etc/ssl/private/zeppelin-self-signed-cert.key -out /etc/ssl/certs/zeppelin-self-signed-cert.pem -days 3650 -subj "/CN=${STANDALONE_DOMAIN}" -nodes
|
||||
|
||||
COPY ./docker/production/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
RUN sed -ir "s/_API_PORT_/${API_PORT}/g" /etc/nginx/conf.d/default.conf
|
||||
RUN sed -ir "s/_DOCKER_PROD_DOMAIN_/${DOCKER_PROD_DOMAIN}/g" /etc/nginx/conf.d/default.conf
|
||||
|
||||
COPY --from=builder /zeppelin/dashboard/dist /var/www
|
||||
RUN sed -ir "s/_STANDALONE_DOMAIN_/${STANDALONE_DOMAIN}/g" /etc/nginx/conf.d/default.conf
|
||||
|
|
|
@ -1,26 +1,24 @@
|
|||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name _DOCKER_PROD_DOMAIN_;
|
||||
|
||||
root /var/www;
|
||||
|
||||
location / {
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
server_name _STANDALONE_DOMAIN_;
|
||||
|
||||
# Using a variable here stops nginx from crashing if the dev container is restarted or becomes otherwise unavailable
|
||||
set $backend_upstream "http://api:_API_PORT_";
|
||||
set $backend_upstream "http://api:3001";
|
||||
set $dashboard_upstream "http://dashboard:3002";
|
||||
|
||||
location / {
|
||||
# Using a variable in proxy_pass also requires resolver to be set.
|
||||
# This is the address of the internal docker compose DNS server.
|
||||
resolver 127.0.0.11;
|
||||
proxy_pass $dashboard_upstream$uri$is_args$args;
|
||||
}
|
||||
|
||||
location /api {
|
||||
# Remove /api/ from the beginning when passing the path to the API process
|
||||
rewrite /api(/.*)$ $1 break;
|
||||
|
||||
# Using a variable in proxy_pass also requires resolver to be set.
|
||||
# This is the address of the internal docker compose DNS server.
|
||||
resolver 127.0.0.11;
|
||||
|
||||
proxy_pass $backend_upstream$uri$is_args$args;
|
||||
proxy_redirect off;
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This wrapper script is used to run different things based on the DEBUG env variable
|
||||
# Exec is used to forward signals: https://unix.stackexchange.com/a/196053
|
||||
|
||||
cd /zeppelin/backend
|
||||
if [ "$DEBUG" == "true" ]; then
|
||||
echo "DEBUG MODE: Starting bot container without starting the bot"
|
||||
exec tail -f /dev/null
|
||||
else
|
||||
echo "Starting bot"
|
||||
exec npm run start-bot-prod
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue