budibase/hosting/single/Dockerfile

122 lines
4.3 KiB
Docker
Raw Normal View History

2023-12-22 15:05:42 +01:00
FROM node:20-slim as build
# install node-gyp dependencies
2023-11-24 13:02:14 +01:00
RUN apt-get update && apt-get install -y --no-install-recommends g++ make python3 jq
2023-11-24 13:02:14 +01:00
# copy and install dependencies
WORKDIR /app
2023-11-24 13:02:14 +01:00
COPY package.json .
2023-06-07 10:15:11 +02:00
COPY yarn.lock .
2023-11-24 13:02:14 +01:00
COPY lerna.json .
COPY .yarnrc .
COPY packages/server/package.json packages/server/package.json
COPY packages/worker/package.json packages/worker/package.json
COPY scripts/removeWorkspaceDependencies.sh scripts/removeWorkspaceDependencies.sh
RUN chmod +x ./scripts/removeWorkspaceDependencies.sh
RUN ./scripts/removeWorkspaceDependencies.sh packages/server/package.json
RUN ./scripts/removeWorkspaceDependencies.sh packages/worker/package.json
2023-11-24 13:02:14 +01:00
# We will never want to sync pro, but the script is still required
RUN echo '' > scripts/syncProPackage.js
RUN jq 'del(.scripts.postinstall)' package.json > temp.json && mv temp.json package.json
RUN ./scripts/removeWorkspaceDependencies.sh package.json
RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn install --production --frozen-lockfile
2023-11-24 13:02:14 +01:00
# copy the actual code
COPY packages/server/dist packages/server/dist
COPY packages/server/pm2.config.js packages/server/pm2.config.js
COPY packages/server/client packages/server/client
COPY packages/server/builder packages/server/builder
COPY packages/worker/dist packages/worker/dist
COPY packages/worker/pm2.config.js packages/worker/pm2.config.js
2024-02-20 13:14:49 +01:00
FROM budibase/couchdb:v3.3.3 as runner
ARG TARGETARCH
ENV TARGETARCH $TARGETARCH
2022-06-24 18:48:34 +02:00
#TARGETBUILD can be set to single (for single docker image) or aas (for azure app service)
# e.g. docker build --build-arg TARGETBUILD=aas ....
2022-08-11 13:08:56 +02:00
ARG TARGETBUILD=single
2022-06-24 18:48:34 +02:00
ENV TARGETBUILD $TARGETBUILD
# install base dependencies
RUN apt-get update && \
2023-11-24 13:02:14 +01:00
apt-get install -y --no-install-recommends software-properties-common nginx uuid-runtime redis-server libaio1
2023-06-22 12:29:32 +02:00
# Install postgres client for pg_dump utils
2023-11-24 13:02:14 +01:00
RUN apt install -y software-properties-common apt-transport-https ca-certificates gnupg \
2024-03-15 13:55:29 +01:00
&& curl -fsSl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null \
&& echo deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main | tee /etc/apt/sources.list.d/postgresql.list \
&& apt update -y \
&& apt install postgresql-client-15 -y \
&& apt remove software-properties-common apt-transport-https gpg -y
2023-06-22 12:29:32 +02:00
# We use pm2 in order to run multiple node processes in a single container
RUN npm install --global pm2
2022-04-01 02:00:52 +02:00
2022-04-05 12:33:55 +02:00
# setup nginx
2023-11-24 13:02:14 +01:00
COPY hosting/single/nginx/nginx.conf /etc/nginx
COPY hosting/single/nginx/nginx-default-site.conf /etc/nginx/sites-enabled/default
2022-06-22 14:38:33 +02:00
RUN mkdir -p /var/log/nginx && \
touch /var/log/nginx/error.log && \
2022-12-06 11:58:13 +01:00
touch /var/run/nginx.pid && \
usermod -a -G tty www-data
2022-04-01 02:00:52 +02:00
WORKDIR /
RUN mkdir -p scripts/integrations/oracle
2023-11-24 13:02:14 +01:00
COPY packages/server/scripts/integrations/oracle scripts/integrations/oracle
RUN /bin/bash -e ./scripts/integrations/oracle/instantclient/linux/install.sh
2022-04-01 02:00:52 +02:00
# setup minio
WORKDIR /minio
2023-11-24 13:02:14 +01:00
COPY scripts/install-minio.sh ./install.sh
2022-06-22 13:40:33 +02:00
RUN chmod +x install.sh && ./install.sh
2022-04-01 02:00:52 +02:00
2022-04-05 12:33:55 +02:00
# setup runner file
2022-04-01 02:00:52 +02:00
WORKDIR /
2023-11-24 13:02:14 +01:00
COPY hosting/single/runner.sh .
2022-04-01 02:00:52 +02:00
RUN chmod +x ./runner.sh
2023-11-24 13:02:14 +01:00
COPY hosting/single/healthcheck.sh .
2022-06-22 14:38:33 +02:00
RUN chmod +x ./healthcheck.sh
2022-04-01 02:00:52 +02:00
2022-08-11 13:08:56 +02:00
# Script below sets the path for storing data based on $DATA_DIR
2022-06-24 18:48:34 +02:00
# For Azure App Service install SSH & point data locations to /home
2023-11-24 13:02:14 +01:00
COPY hosting/single/ssh/sshd_config /etc/
COPY hosting/single/ssh/ssh_setup.sh /tmp
# setup letsencrypt certificate
RUN apt-get install -y certbot python3-certbot-nginx
COPY hosting/letsencrypt /app/letsencrypt
RUN chmod +x /app/letsencrypt/certificate-request.sh /app/letsencrypt/certificate-renew.sh
COPY --from=build /app/node_modules /node_modules
COPY --from=build /app/package.json /package.json
COPY --from=build /app/packages/server /app
COPY --from=build /app/packages/worker /worker
2022-06-22 14:38:33 +02:00
EXPOSE 80
EXPOSE 443
2022-09-13 17:08:54 +02:00
# Expose port 2222 for SSH on Azure App Service build
EXPOSE 2222
VOLUME /data
2022-04-01 02:00:52 +02:00
2023-11-24 13:02:14 +01:00
ARG BUDIBASE_VERSION
# Ensuring the version argument is sent
RUN test -n "$BUDIBASE_VERSION"
ENV BUDIBASE_VERSION=$BUDIBASE_VERSION
2022-06-22 14:38:33 +02:00
HEALTHCHECK --interval=15s --timeout=15s --start-period=45s CMD "/healthcheck.sh"
2022-04-01 02:00:52 +02:00
# must set this just before running
ENV NODE_ENV=production
# this is required for isolated-vm to work on Node 20+
ENV NODE_OPTIONS="--no-node-snapshot"
WORKDIR /
2022-04-01 02:00:52 +02:00
CMD ["./runner.sh"]