Skip to content

Commit

Permalink
Fix and simplify Dockerfile; still needs work.
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-mayrgundter committed Oct 18, 2023
1 parent 1a72d57 commit dfafc5e
Show file tree
Hide file tree
Showing 7 changed files with 492 additions and 1,010 deletions.
29 changes: 4 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
FROM node:16-slim AS builder

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y git python3 build-essential libxi-dev libglu1-mesa-dev libglew-dev xvfb pkg-config && \
DEBIAN_FRONTEND=noninteractive apt-get install -y libxi-dev libglu1-mesa-dev libglew-dev xvfb && \
apt-get clean && \
ln -s /usr/bin/python3 /usr/bin/python && \
rm -rf /var/lib/apt/lists/*

WORKDIR /src

COPY ["package.json", "yarn.lock", "./"]
RUN yarn install && \
npm_config_build_from_source=true yarn add --force https://github.com/bldrs-ai/web-ifc-three.git && \
yarn build

COPY . .

FROM node:16-slim AS app

ENV NODE_ENV production

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y git mesa-utils xserver-xorg xvfb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY --from=builder ["/src/package.json", "/src/yarn.lock", "./"]
RUN yarn install --production
COPY --from=builder ["/src/node_modules/web-ifc-three", "./node_modules/web-ifc-three"]
COPY --from=builder /src/src ./
RUN yarn install
RUN yarn build

EXPOSE 8001
CMD ["xvfb-run", "--error-file=/dev/stderr", "--listen-tcp", "--server-args", "-ac -screen 0 1024x768x24 +extension GLX +render", "node", "server.js"]
CMD ["xvfb-run", "--error-file=/dev/stderr", "--listen-tcp", "--server-args", "-ac -screen 0 1024x768x24 +extension GLX +render", "node", "build/server-bundle.js"]
3 changes: 2 additions & 1 deletion esbuild/build.esb.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import esbuild from 'esbuild'
import {webIfcShimAliasPlugin} from './web-ifc-shim-alias-plugin.js'
import {webIfcThreeImportFixupPlugin} from './web-ifc-three-import-fixup.js'


// These usually have dynamic requires that make the bundler or node
Expand Down Expand Up @@ -30,7 +31,7 @@ esbuild
external: externalPackages,
sourcemap: 'inline',
logLevel: 'info',
plugins: [webIfcShimAliasPlugin]
plugins: [webIfcShimAliasPlugin, webIfcThreeImportFixupPlugin]
})
.then((result) => {
console.log('Build succeeded.')
Expand Down
3 changes: 1 addition & 2 deletions esbuild/web-ifc-shim-alias-plugin.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import path from 'node:path'


const __dirname = '/Users/pablo/c/b/headless-three/'
const webIfcShimAliasPlugin = {
name: 'web-ifc-shim-alias',
setup(build) {
build.onResolve({ filter: /^web-ifc$/ }, (args) => {
return {
path: path.resolve(__dirname, './node_modules/bldrs-conway/compiled/src/shim/ifc_api.js'),
path: path.resolve('./node_modules/bldrs-conway/compiled/src/shim/ifc_api.js'),
}
});
},
Expand Down
21 changes: 21 additions & 0 deletions esbuild/web-ifc-three-import-fixup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import fs from 'fs'


const webIfcThreeImportFixupPlugin = {
name: 'web-ifc-three-import-fixup',
setup(build) {
build.onLoad({ filter: /web-ifc-three\/IFCLoader.js/ }, async (args) => {
let contents = await fs.promises.readFile(args.path, 'utf8')

contents = contents.replace(
"import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils';",
"import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';",
)

return { contents, loader: 'js' }
});
},
}


export {webIfcThreeImportFixupPlugin}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"@sentry/node": "^7.64.0",
"axios": "^1.4.0",
"bldrs-conway": "./bldrs-conway-v0.0.1.tgz",
"bldrs-conway": "file:bldrs-conway-v0.0.1.tgz",
"camera-controls": "^2.7.0",
"express": "^4.18.2",
"fetch-blob": "^4.0.0",
Expand All @@ -19,7 +19,7 @@
"pngjs": "^7.0.0",
"three": "^0.149.0",
"web-ifc": "^0.0.41",
"web-ifc-three": "https://github.com/bldrs-ai/web-ifc-three.git",
"web-ifc-three": "^0.0.125",
"web-worker": "^1.2.0",
"xhr2": "^0.2.1"
},
Expand Down
Loading

0 comments on commit dfafc5e

Please sign in to comment.