From f00c8cc69fae78bf312e57c64afb432f7d9e8116 Mon Sep 17 00:00:00 2001 From: Jonny McCullagh Date: Fri, 24 Jun 2022 17:48:34 +0100 Subject: [PATCH] add support for Azure App Service --- hosting/scripts/build-target-paths.sh | 17 +++++++++++++++++ hosting/single/Dockerfile | 13 ++++++++++++- hosting/single/test.sh | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 hosting/scripts/build-target-paths.sh diff --git a/hosting/scripts/build-target-paths.sh b/hosting/scripts/build-target-paths.sh new file mode 100644 index 0000000000..d1c9b5cd05 --- /dev/null +++ b/hosting/scripts/build-target-paths.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo ${TARGETBUILD} > /buildtarget.txt +if [[ "${TARGETBUILD}" = "aas" ]]; then + # Azure AppService uses /home for persisent data & SSH on port 2222 + mkdir -p /home/budibase/{minio,couchdb} + mkdir -p /home/budibase/couchdb/data + chown -R couchdb:couchdb /home/budibase/couchdb/ + apt update + apt-get install -y openssh-server + sed -i 's#dir=/opt/couchdb/data/search#dir=/home/budibase/couchdb/data/search#' /opt/clouseau/clouseau.ini + sed -i 's#/minio/minio server /minio &#/minio/minio server /home/budibase/minio &#' /runner.sh + sed -i 's#database_dir = ./data#database_dir = /home/budibase/couchdb/data#' /opt/couchdb/etc/default.ini + sed -i 's#view_index_dir = ./data#view_index_dir = /home/budibase/couchdb/data#' /opt/couchdb/etc/default.ini + sed -i "s/#Port 22/Port 2222/" /etc/ssh/sshd_config + /etc/init.d/ssh restart +fi diff --git a/hosting/single/Dockerfile b/hosting/single/Dockerfile index 1b97c200eb..c34a06e92d 100644 --- a/hosting/single/Dockerfile +++ b/hosting/single/Dockerfile @@ -19,8 +19,12 @@ ADD packages/worker . RUN node /pinVersions.js && yarn && yarn build && /cleanup.sh FROM couchdb:3.2.1 - +# TARGETARCH can be amd64 or arm e.g. docker build --build-arg TARGETARCH=amd64 ARG TARGETARCH amd64 +#TARGETBUILD can be set to single (for single docker image) or aas (for azure app service) +# e.g. docker build --build-arg TARGETBUILD=aas .... +ARG TARGETBUILD single +ENV TARGETBUILD $TARGETBUILD COPY --from=build /app /app COPY --from=build /worker /worker @@ -44,6 +48,7 @@ ENV \ REDIS_PASSWORD=budibase \ REDIS_URL=localhost:6379 \ SELF_HOSTED=1 \ + TARGETBUILD=$TARGETBUILD \ WORKER_PORT=4002 \ WORKER_URL=http://localhost:4002 @@ -101,6 +106,12 @@ RUN chmod +x ./runner.sh ADD hosting/scripts/healthcheck.sh . RUN chmod +x ./healthcheck.sh +ADD hosting/scripts/build-target-paths.sh . +RUN chmod +x ./build-target-paths.sh + +# For Azure App Service install SSH & point data locations to /home +RUN /build-target-paths.sh + # cleanup cache RUN yarn cache clean -f diff --git a/hosting/single/test.sh b/hosting/single/test.sh index b9f9a4032c..c7ef53f994 100755 --- a/hosting/single/test.sh +++ b/hosting/single/test.sh @@ -1,4 +1,4 @@ #!/bin/bash -id=$(docker run -t -d -p 10000:10000 budibase:latest) +id=$(docker run -t -d -p 80:80 budibase:latest) docker exec -it $id bash docker kill $id