2023-06-07 12:11:13 +02:00
FROM node:14-slim as build
2022-06-16 21:38:24 +02:00
# install node-gyp dependencies
2023-06-22 13:25:27 +02:00
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends apt-utils cron g++ make python
2022-06-16 21:38:24 +02:00
# add pin script
WORKDIR /
2023-05-24 17:23:34 +02:00
ADD scripts/cleanup.sh ./
2022-06-16 21:38:24 +02:00
RUN chmod +x /cleanup.sh
# build server
WORKDIR /app
ADD packages/server .
2023-06-07 10:15:11 +02:00
COPY yarn.lock .
2023-06-07 12:11:13 +02:00
RUN yarn install --production= true
RUN /cleanup.sh
2022-06-16 21:38:24 +02:00
# build worker
WORKDIR /worker
ADD packages/worker .
2023-06-07 10:15:11 +02:00
COPY yarn.lock .
2023-06-07 12:11:13 +02:00
RUN yarn install --production= true
RUN /cleanup.sh
2022-06-16 21:38:24 +02:00
2022-12-09 23:11:15 +01:00
FROM budibase/couchdb
2022-10-06 15:05:01 +02:00
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)
2023-05-03 19:22:19 +02:00
# 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
2022-06-21 18:56:55 +02:00
2022-06-16 21:38:24 +02:00
COPY --from= build /app /app
COPY --from= build /worker /worker
2022-06-16 20:30:34 +02:00
# install base dependencies
RUN apt-get update && \
2023-05-24 17:23:34 +02:00
apt-get install -y --no-install-recommends software-properties-common nginx uuid-runtime redis-server
2022-06-16 20:30:34 +02:00
2023-06-22 12:29:32 +02: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
2022-06-16 20:30:34 +02:00
# install other dependencies, nodejs, oracle requirements, jdk8, redis, nginx
WORKDIR /nodejs
RUN curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh && \
bash /tmp/nodesource_setup.sh && \
2022-12-01 18:08:49 +01:00
apt-get install -y --no-install-recommends libaio1 nodejs && \
2022-06-16 20:30:34 +02:00
npm install --global yarn pm2
2022-04-01 02:00:52 +02:00
2022-04-05 12:33:55 +02:00
# setup nginx
2022-07-08 15:28:09 +02:00
ADD hosting/single/nginx/nginx.conf /etc/nginx
ADD 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
2022-06-16 20:30:34 +02:00
WORKDIR /
2022-06-16 21:38:24 +02:00
RUN mkdir -p scripts/integrations/oracle
ADD packages/server/scripts/integrations/oracle scripts/integrations/oracle
2022-06-21 18:56:55 +02:00
RUN /bin/bash -e ./scripts/integrations/oracle/instantclient/linux/install.sh
2022-04-01 02:00:52 +02:00
# setup minio
WORKDIR /minio
2022-06-22 13:40:33 +02:00
ADD scripts/install-minio.sh ./install.sh
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 /
ADD hosting/single/runner.sh .
RUN chmod +x ./runner.sh
2022-07-19 15:39:52 +02:00
ADD 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
2022-09-13 17:08:54 +02:00
ADD hosting/single/ssh/sshd_config /etc/
ADD hosting/single/ssh/ssh_setup.sh /tmp
2022-06-24 18:48:34 +02:00
RUN /build-target-paths.sh
2022-06-16 21:38:24 +02:00
# cleanup cache
RUN yarn cache clean -f
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
2022-07-15 12:08:03 +02:00
VOLUME /data
2022-04-01 02:00:52 +02:00
2022-06-22 14:38:33 +02:00
# setup letsencrypt certificate
RUN apt-get install -y certbot python3-certbot-nginx
ADD hosting/letsencrypt /app/letsencrypt
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 02:00:52 +02:00
# must set this just before running
ENV NODE_ENV = production
2022-06-16 21:38:24 +02:00
WORKDIR /
2022-04-01 02:00:52 +02:00
CMD [ "./runner.sh" ]