From f11c0025c07b3ca5c11c8dfb5ce7c4c7716330c0 Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 10 Aug 2022 12:46:01 +0800 Subject: [PATCH] feat: full version of the NocoBase dockerfile (#719) --- Dockerfile | 31 +++++++++++++++++++++++ docker/nocobase-full/docker-entrypoint.sh | 19 ++++++++++++++ docker/nocobase-full/nocobase.conf | 26 +++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 Dockerfile create mode 100755 docker/nocobase-full/docker-entrypoint.sh create mode 100644 docker/nocobase-full/nocobase.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..28bbf8203 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM node:16-stretch-slim + +WORKDIR /app/nocobase + +# COPY ./docker/nocobase/sources.list /etc/apt/sources.list + +RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ + && case "${dpkgArch##*-}" in \ + amd64) ARCH='x64';; \ + ppc64el) ARCH='ppc64le';; \ + s390x) ARCH='s390x';; \ + arm64) ARCH='arm64';; \ + armhf) ARCH='armv7l';; \ + i386) ARCH='x86';; \ + *) echo "unsupported architecture"; exit 1 ;; \ + esac \ + && set -ex \ + # libatomic1 for arm + && apt-get update && apt-get install -y nginx + +RUN rm -rf /etc/nginx/sites-enabled/default +COPY ./docker/nocobase-full/nocobase.conf /etc/nginx/sites-enabled/nocobase.conf +COPY . /app/nocobase +RUN cd /app/nocobase & yarn install +RUN cd /app/nocobase & yarn build + +COPY ./docker/nocobase-full/docker-entrypoint.sh /app/ +# COPY docker-entrypoint.sh /usr/local/bin/ +# ENTRYPOINT ["docker-entrypoint.sh"] + +CMD ["/app/docker-entrypoint.sh"] diff --git a/docker/nocobase-full/docker-entrypoint.sh b/docker/nocobase-full/docker-entrypoint.sh new file mode 100755 index 000000000..c81b3963a --- /dev/null +++ b/docker/nocobase-full/docker-entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +nginx +echo 'nginx started'; + +cd /app/nocobase && yarn nocobase db:auth --retry=30 +cd /app/nocobase && yarn nocobase install -s +cd /app/nocobase && yarn nocobase upgrade -S +cd /app/nocobase && yarn start + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +exec "$@" diff --git a/docker/nocobase-full/nocobase.conf b/docker/nocobase-full/nocobase.conf new file mode 100644 index 000000000..57d5ae427 --- /dev/null +++ b/docker/nocobase-full/nocobase.conf @@ -0,0 +1,26 @@ +server { + listen 80; + server_name _; + root /app/nocobase/packages/app/client/dist; + index index.html; + client_max_body_size 20M; + + location /storage/uploads/ { + alias /app/nocobase/storage/uploads/; + autoindex off; + } + + location / { + root /app/nocobase/packages/app/client/dist; + try_files $uri $uri/ /index.html; + } + + location ^~ /api/ { + proxy_pass http://127.0.0.1:13000/api/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } +}