Updating the single image docker build to pin versions before build to allow it to work with develop etc. Also optimising the image a bit so that it can be built significantly faster.

This commit is contained in:
mike12345567 2022-06-16 19:30:34 +01:00
parent 48dc729f9a
commit a3607842ef
3 changed files with 85 additions and 81 deletions

View File

@ -1,79 +1,71 @@
FROM couchdb FROM couchdb:3.2.1
ENV DEPLOYMENT_ENVIRONMENT=docker ENV DEPLOYMENT_ENVIRONMENT=docker \
ENV POSTHOG_TOKEN=phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS POSTHOG_TOKEN=phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS \
ENV COUCHDB_PASSWORD=budibase COUCHDB_PASSWORD=budibase \
ENV COUCHDB_USER=budibase COUCHDB_USER=budibase \
ENV COUCH_DB_URL=http://budibase:budibase@localhost:5984 COUCH_DB_URL=http://budibase:budibase@localhost:5984 \
ENV BUDIBASE_ENVIRONMENT=PRODUCTION BUDIBASE_ENVIRONMENT=PRODUCTION \
ENV MINIO_URL=http://localhost:9000 MINIO_URL=http://localhost:9000 \
ENV REDIS_URL=localhost:6379 REDIS_URL=localhost:6379 \
ENV WORKER_URL=http://localhost:4002 WORKER_URL=http://localhost:4002 \
ENV INTERNAL_API_KEY=budibase INTERNAL_API_KEY=budibase \
ENV JWT_SECRET=testsecret JWT_SECRET=testsecret \
ENV MINIO_ACCESS_KEY=budibase MINIO_ACCESS_KEY=budibase \
ENV MINIO_SECRET_KEY=budibase MINIO_SECRET_KEY=budibase \
ENV SELF_HOSTED=1 SELF_HOSTED=1 \
ENV CLUSTER_PORT=10000 CLUSTER_PORT=10000 \
ENV REDIS_PASSWORD=budibase REDIS_PASSWORD=budibase \
ENV ARCHITECTURE=amd ARCHITECTURE=amd \
ENV APP_PORT=4001 APP_PORT=4001 \
ENV WORKER_PORT=4002 WORKER_PORT=4002
RUN apt-get update # install base dependencies
RUN apt-get install software-properties-common wget nginx -y RUN apt-get update && \
RUN apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main' apt-get install software-properties-common wget -y && \
RUN apt-get update apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main' && \
apt-get update
# 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 && \
apt-get install libaio1 nodejs nginx openjdk-8-jdk redis-server unzip -y && \
npm install --global yarn pm2
# setup nginx # setup nginx
ADD hosting/single/nginx.conf /etc/nginx ADD hosting/single/nginx.conf /etc/nginx
RUN mkdir /etc/nginx/logs RUN mkdir /etc/nginx/logs && \
RUN useradd www useradd www && \
RUN touch /etc/nginx/logs/error.log touch /etc/nginx/logs/error.log && \
RUN touch /etc/nginx/logs/nginx.pid touch /etc/nginx/logs/nginx.pid
# install java # add pin script
RUN apt-get install openjdk-8-jdk -y WORKDIR /
ADD scripts/pinVersions.js .
# setup nodejs # setup server and install client for oracle datasource
WORKDIR /nodejs
RUN curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh
RUN bash /tmp/nodesource_setup.sh
RUN apt-get install nodejs
RUN npm install --global yarn
RUN npm install --global pm2
# setup redis
RUN apt install redis-server -y
# setup server
WORKDIR /app WORKDIR /app
ADD packages/server . ADD packages/server .
RUN ls -al RUN node /pinVersions.js && yarn && yarn build && \
RUN yarn /bin/bash -e scripts/integrations/oracle/instantclient/linux/x86-64/install.sh
RUN yarn build
# Install client for oracle datasource
RUN apt-get install unzip libaio1
RUN /bin/bash -e scripts/integrations/oracle/instantclient/linux/x86-64/install.sh
# setup worker # setup worker
WORKDIR /worker WORKDIR /worker
ADD packages/worker . ADD packages/worker .
RUN yarn RUN node /pinVersions.js && yarn && yarn build
RUN yarn build
# setup clouseau # setup clouseau
WORKDIR / WORKDIR /
RUN wget https://github.com/cloudant-labs/clouseau/releases/download/2.21.0/clouseau-2.21.0-dist.zip RUN wget https://github.com/cloudant-labs/clouseau/releases/download/2.21.0/clouseau-2.21.0-dist.zip && \
RUN unzip clouseau-2.21.0-dist.zip unzip clouseau-2.21.0-dist.zip && \
RUN mv clouseau-2.21.0 /opt/clouseau mv clouseau-2.21.0 /opt/clouseau && \
RUN rm clouseau-2.21.0-dist.zip rm clouseau-2.21.0-dist.zip
WORKDIR /opt/clouseau WORKDIR /opt/clouseau
RUN mkdir ./bin RUN mkdir ./bin
ADD hosting/single/clouseau ./bin/ ADD hosting/single/clouseau ./bin/
ADD hosting/single/log4j.properties . ADD hosting/single/log4j.properties hosting/single/clouseau.ini ./
ADD hosting/single/clouseau.ini .
RUN chmod +x ./bin/clouseau RUN chmod +x ./bin/clouseau
# setup CouchDB # setup CouchDB
@ -82,8 +74,7 @@ ADD hosting/single/vm.args ./etc/
# setup minio # setup minio
WORKDIR /minio WORKDIR /minio
RUN wget https://dl.min.io/server/minio/release/linux-${ARCHITECTURE}64/minio RUN wget https://dl.min.io/server/minio/release/linux-${ARCHITECTURE}64/minio && chmod +x minio
RUN chmod +x minio
# setup runner file # setup runner file
WORKDIR / WORKDIR /

4
hosting/single/test.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
id=$(docker run -t -d -p 10000:10000 budibase:latest)
docker exec -it $id bash
docker kill $id

View File

@ -3,35 +3,44 @@ const path = require("path")
const MONOREPO_ROOT = "packages" const MONOREPO_ROOT = "packages"
const packages = fs.readdirSync(MONOREPO_ROOT) const packages = getPackages()
function getPackages() {
if (fs.existsSync(MONOREPO_ROOT)) {
return fs.readdirSync(MONOREPO_ROOT).map(pkg => path.join(MONOREPO_ROOT, pkg))
} else {
return ["./"]
}
}
function pinDeps(dependencies) { function pinDeps(dependencies) {
for (let dependency in dependencies) { for (let dependency in dependencies) {
if (dependency.startsWith("@budibase")) { if (dependency.startsWith("@budibase")) {
dependencies[dependency] = dependencies[dependency].replace("^", "") dependencies[dependency] = dependencies[dependency].replace("^", "")
} }
} }
return dependencies
} }
// iterate over the monorepo packages // iterate over the monorepo packages
for (let pkg of packages) { for (let pkgPath of packages) {
const pkgPath = path.join(MONOREPO_ROOT, pkg) // only directories
if (fs.statSync(pkgPath).isDirectory()) {
// only directories // get the package JSON file
if (fs.statSync(pkgPath).isDirectory()) { const pkgJsonPath = path.join(pkgPath, "package.json")
if (!fs.existsSync(pkgJsonPath)) {
continue
}
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath))
// get the package JSON file // find any budibase dependencies, and pin them
const pkgJsonPath = path.join(pkgPath, "package.json") pkgJson.dependencies = pinDeps(pkgJson.dependencies)
const pkgJson = require(`../${pkgJsonPath}`) pkgJson.devDependencies = pinDeps(pkgJson.devDependencies)
// find any budibase dependencies, and pin them // update the package JSON files
pinDeps(pkgJson.dependencies) fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2))
pinDeps(pkgJson.devDependencies) }
// update the package JSON files
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2))
}
} }
console.log("Pinned dev versions for budibase packages successfully.") console.log("Pinned dev versions for budibase packages successfully.")