Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update how we build the single image. #15101

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 79 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,84 @@
*
!/packages/
!/scripts/
/packages/*/node_modules
packages/server/scripts/
!packages/server/scripts/integrations/oracle

!packages/server/package.json
!packages/server/tsconfig.json
!packages/server/tsconfig.build.json
!packages/server/src/
!packages/server/scripts/build.js
!packages/server/docker_run.sh
!packages/server/builder/
!packages/server/client/

!packages/worker/package.json
!packages/worker/tsconfig.json
!packages/worker/tsconfig.build.json
!packages/worker/src/
!packages/worker/docker_run.sh

!packages/pro/package.json
!packages/pro/tsconfig.json
!packages/pro/tsconfig.build.json
!packages/pro/src/

!packages/types/src
!packages/types/package.json
!packages/types/tsconfig.json
!packages/types/tsconfig.build.json

!packages/shared-core/src
!packages/shared-core/package.json
!packages/shared-core/tsconfig.json
!packages/shared-core/tsconfig.build.json

!packages/backend-core/src
!packages/backend-core/package.json
!packages/backend-core/tsconfig.json
!packages/backend-core/tsconfig.build.json
!packages/backend-core/scripts/build.js
!packages/backend-core/jest.config.ts

!packages/frontend-core/src
!packages/frontend-core/package.json
!packages/frontend-core/assets

!packages/bbui/src
!packages/bbui/package.json
!packages/bbui/vite.config.js

!packages/builder/src
!packages/builder/package.json
!packages/builder/tsconfig.json
!packages/builder/tsconfig.build.json
!packages/builder/public
!packages/builder/assets
!packages/builder/.routify
!packages/builder/nuxt.config.js
!packages/builder/routify.config.js
!packages/builder/vite.config.mjs
!packages/builder/index.html
!packages/builder/babel.config.js
!packages/builder/svelte.config.js

!packages/sdk/src
!packages/sdk/package.json
!packages/sdk/rollup.config.js

!packages/client/src
!packages/client/package.json
!packages/client/tsconfig.json
!packages/client/manifest.json
!packages/client/vite.config.mjs

!packages/string-templates/src
!packages/string-templates/package.json
!packages/string-templates/tsconfig.json
!packages/string-templates/rollup.config.js

!scripts/
!nx.json
!/hosting/single/
!/hosting/letsencrypt /

!hosting/single/
!hosting/letsencrypt/

!package.json
!yarn.lock
Expand Down
58 changes: 31 additions & 27 deletions hosting/single/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG BASEIMG=budibase/couchdb:v3.3.3-sqs-v2.1.1
FROM node:20-slim as build
FROM node:20-slim AS build

# install node-gyp dependencies
RUN apt-get update && apt-get install -y --no-install-recommends g++ make python3 jq
Expand All @@ -11,48 +11,52 @@ COPY yarn.lock .
COPY lerna.json .
COPY .yarnrc .

COPY packages/server/package.json packages/server/package.json
COPY packages/types/package.json packages/types/package.json
COPY packages/shared-core/package.json packages/shared-core/package.json
COPY packages/backend-core/package.json packages/backend-core/package.json
COPY packages/frontend-core/package.json packages/frontend-core/package.json
COPY packages/bbui/package.json packages/bbui/package.json
COPY packages/builder/package.json packages/builder/package.json
COPY packages/sdk/package.json packages/sdk/package.json
COPY packages/client/package.json packages/client/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
COPY packages/server/package.json packages/server/package.json
COPY packages/string-templates/package.json packages/string-templates/package.json
COPY packages/pro/package.json packages/pro/package.json

RUN jq 'del(.scripts.postinstall)' package.json > temp.json && mv temp.json package.json
RUN ./scripts/removeWorkspaceDependencies.sh package.json
ARG TARGETPLATFORM
RUN --mount=type=cache,target=/root/.yarn/${TARGETPLATFORM} YARN_CACHE_FOLDER=/root/.yarn/${TARGETPLATFORM} yarn install --production --frozen-lockfile
RUN yarn install --frozen-lockfile

COPY . .

# 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
RUN yarn build

# Prune non-production dependencies
RUN yarn install --production --ignore-scripts --prefer-offline

FROM $BASEIMG as runner
FROM $BASEIMG AS runner
ARG TARGETARCH
ENV TARGETARCH $TARGETARCH
ENV TARGETARCH=$TARGETARCH
#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
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 libaio1
apt-get install -y --no-install-recommends software-properties-common nginx uuid-runtime redis-server libaio1 certbot python3-certbot-nginx && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install postgres client for pg_dump utils
RUN apt install -y software-properties-common apt-transport-https ca-certificates gnupg \
&& 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
&& apt remove software-properties-common apt-transport-https gpg -y \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

# We use pm2 in order to run multiple node processes in a single container
RUN npm install --global pm2
Expand Down Expand Up @@ -86,15 +90,15 @@ 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

COPY --from=build /app/packages/server/package.json /app/package.json
COPY --from=build /app/packages/server/dist /app/dist
COPY --from=build /app/packages/worker/package.json /worker/package.json
COPY --from=build /app/packages/worker/dist /worker/dist

EXPOSE 80
EXPOSE 443
Expand Down
7 changes: 0 additions & 7 deletions packages/server/.dockerignore

This file was deleted.

1 change: 1 addition & 0 deletions packages/server/src/sdk/app/datasources/datasources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ async function enrichDatasourceWithValues(
datasource: Datasource,
variables?: Record<string, string>
) {
console.log("wtf")
const cloned = cloneDeep(datasource)
const env = variables ? variables : await getEnvironmentVariables()
//Do not process entities, as we do not want to process formulas
Expand Down
4 changes: 0 additions & 4 deletions packages/worker/.dockerignore

This file was deleted.

Loading