1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00
budibase/hosting/single/Dockerfile

122 lines
3.9 KiB
Docker
Raw Normal View History

FROM node:18-slim as build
# install node-gyp dependencies
2023-10-03 05:26:47 +13:00
RUN apt-get update && apt-get install -y --no-install-recommends g++ make python3 jq
2023-10-03 05:18:42 +13:00
# copy and install dependencies
WORKDIR /app
2023-10-03 05:18:42 +13:00
COPY package.json .
2023-06-07 20:15:11 +12:00
COPY yarn.lock .
2023-10-03 05:18:42 +13:00
COPY lerna.json .
COPY .yarnrc .
2023-10-03 05:26:47 +13:00
COPY scripts/removeWorkspaceDependencies.sh scripts/removeWorkspaceDependencies.sh
RUN ./scripts/removeWorkspaceDependencies.sh package.json
RUN ./scripts/removeWorkspaceDependencies.sh packages/server/package.json
RUN ./scripts/removeWorkspaceDependencies.sh packages/worker/package.json
2023-10-03 05:18:42 +13:00
# We will never want to sync pro, but the script is still required
2023-10-03 05:26:47 +13:00
RUN echo '' > scripts/syncProPackage.js
2023-10-03 10:55:07 +13:00
RUN yarn install --frozen-lockfile --production=true && yarn cache clean
2023-10-03 05:18:42 +13:00
# copy the actual code
COPY packages/server/dist packages/server/dist
COPY packages/server/client packages/server/client
2023-10-03 09:39:02 +13:00
COPY packages/worker/dist packages/worker/dist
2023-10-03 05:26:47 +13:00
RUN rm -rf scripts/
2023-10-03 06:14:12 +13:00
FROM budibase/couchdb as runner
ARG TARGETARCH
ENV TARGETARCH $TARGETARCH
2022-06-25 04:48:34 +12: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 23:08:56 +12:00
ARG TARGETBUILD=single
2022-06-25 04:48:34 +12:00
ENV TARGETBUILD $TARGETBUILD
# install base dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends software-properties-common nginx uuid-runtime redis-server
2023-06-22 22:29:32 +12:00
# Install postgres client for pg_dump utils
RUN apt install software-properties-common apt-transport-https gpg -y \
&& 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
# install other dependencies, nodejs, oracle requirements, jdk8, redis, nginx
WORKDIR /nodejs
2023-10-03 09:35:29 +13:00
RUN curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh && \
bash /tmp/nodesource_setup.sh && \
apt-get install -y --no-install-recommends libaio1 nodejs && \
npm install --global yarn pm2
2022-04-01 13:00:52 +13:00
2022-04-05 22:33:55 +12:00
# setup nginx
2023-10-03 05:18:42 +13:00
COPY hosting/single/nginx/nginx.conf /etc/nginx
COPY hosting/single/nginx/nginx-default-site.conf /etc/nginx/sites-enabled/default
2022-06-23 00:38:33 +12:00
RUN mkdir -p /var/log/nginx && \
touch /var/log/nginx/error.log && \
2022-12-06 23:58:13 +13:00
touch /var/run/nginx.pid && \
usermod -a -G tty www-data
2022-04-01 13:00:52 +13:00
WORKDIR /
RUN mkdir -p scripts/integrations/oracle
2023-10-03 05:18:42 +13:00
COPY packages/server/scripts/integrations/oracle scripts/integrations/oracle
RUN /bin/bash -e ./scripts/integrations/oracle/instantclient/linux/install.sh
2022-04-01 13:00:52 +13:00
# setup minio
WORKDIR /minio
2023-10-03 05:18:42 +13:00
COPY scripts/install-minio.sh ./install.sh
2022-06-22 23:40:33 +12:00
RUN chmod +x install.sh && ./install.sh
2022-04-01 13:00:52 +13:00
2022-04-05 22:33:55 +12:00
# setup runner file
2022-04-01 13:00:52 +13:00
WORKDIR /
2023-10-03 05:18:42 +13:00
COPY hosting/single/runner.sh .
2022-04-01 13:00:52 +13:00
RUN chmod +x ./runner.sh
2023-10-03 05:18:42 +13:00
COPY hosting/single/healthcheck.sh .
2022-06-23 00:38:33 +12:00
RUN chmod +x ./healthcheck.sh
2022-04-01 13:00:52 +13:00
2022-08-11 23:08:56 +12:00
# Script below sets the path for storing data based on $DATA_DIR
2022-06-25 04:48:34 +12:00
# For Azure App Service install SSH & point data locations to /home
2023-10-03 05:18:42 +13:00
COPY hosting/single/ssh/sshd_config /etc/
COPY hosting/single/ssh/ssh_setup.sh /tmp
2022-06-25 04:48:34 +12:00
RUN /build-target-paths.sh
2023-10-03 05:18:42 +13:00
COPY --from=build /app /app
2022-06-23 00:38:33 +12:00
EXPOSE 80
EXPOSE 443
2022-09-14 03:08:54 +12:00
# Expose port 2222 for SSH on Azure App Service build
EXPOSE 2222
VOLUME /data
2022-04-01 13:00:52 +13:00
2022-06-23 00:38:33 +12:00
# setup letsencrypt certificate
RUN apt-get install -y certbot python3-certbot-nginx
2023-10-03 05:18:42 +13:00
COPY hosting/letsencrypt /app/letsencrypt
2022-06-23 00:38:33 +12:00
RUN chmod +x /app/letsencrypt/certificate-request.sh /app/letsencrypt/certificate-renew.sh
# Remove cached files
RUN rm -rf \
/root/.cache \
/root/.npm \
/root/.pip \
/usr/local/share/doc \
/usr/share/doc \
/usr/share/man \
/var/lib/apt/lists/* \
/tmp/*
HEALTHCHECK --interval=15s --timeout=15s --start-period=45s CMD "/healthcheck.sh"
2022-04-01 13:00:52 +13:00
# must set this just before running
ENV NODE_ENV=production
WORKDIR /
2022-04-01 13:00:52 +13:00
CMD ["./runner.sh"]