Skip to content

Conversation

@biltongza
Copy link
Contributor

@biltongza biltongza commented Jan 18, 2025

This PR does a couple things:

  • According to the turbo docs we should be specifying rootDir in our tsconfigs so that's added
  • use tsup to build & bundle server
    • this required moving dependencies to devDependencies in package.json, otherwise the built file doesn't run due to missing modules
  • adds the COATRACK_DATA_DIR env var for server that specifies where the data directory should be.
  • adds a Dockerfile to create a docker image to run the app

I decided to use PM2 to serve web + sandbox + run server. Currently web & sandbox are not responding for some reason.

Also, we have a bigger problem, since we're using server as the app "host", and it dynamically picks ports, docker wants to know what the ports are upfront... soooooo we can expose the "known" ports (i.e. 3000, 4000, 5000) but none of the apps in the catalog are exposed.

This is what I'm using to build:

docker build -t coatrack --build-arg ARCH=arm64v8/ . 

And to run:

docker run -v ./stuff:/data -p 4000:4000 -p 3000:3000 -p 5000:5000 coatrack 

@biltongza biltongza added enhancement New feature or request draft core Core platform and infrastructure labels Jan 18, 2025
@biltongza biltongza force-pushed the feature/docker-container branch from f165a96 to c6b7e7c Compare January 18, 2025 20:18
Dockerfile Outdated
USER node
EXPOSE 3000/tcp
EXPOSE 4000/tcp
EXPOSE 5000/tcp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we handle exposing app ports? since those are dynamic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good question one I do not have an answer to

import { initDb } from "./db"

const appServers: Partial<Record<string, Server>> = {}
const dataDir = process.env["COATRACK_DATA_DIR"] || "_data"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add types for the env (using a d.ts, you can probably find docs online) and also/alternatively add a Zod schema and make this a bit of a more general config thing

@@ -0,0 +1,24 @@
module.exports = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha are we using pm2 ? docker should be able to keep these alive on its own so this isnt necessary when containerizing is it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would maybe leave this out if we dont really need it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup pm2, we need it to serve web + sandbox and also host server. otherwise we probably need docker-compose.

Copy link
Contributor

@nabeelvalley nabeelvalley Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah okay i see, probably also good to have for hosting outside of docker e.g as an os image

@nabeelvalley nabeelvalley linked an issue Mar 14, 2025 that may be closed by this pull request
@nabeelvalley nabeelvalley marked this pull request as draft May 15, 2025 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core platform and infrastructure enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creating a custom raspberry pi image

3 participants