Skip to content

Add file to create a docker container for the HTTP server#24

Merged
GICodeWarrior merged 2 commits intoGICodeWarrior:mainfrom
HaasCM:haascm/add-dockerized-server
Apr 21, 2025
Merged

Add file to create a docker container for the HTTP server#24
GICodeWarrior merged 2 commits intoGICodeWarrior:mainfrom
HaasCM:haascm/add-dockerized-server

Conversation

@HaasCM
Copy link
Copy Markdown
Contributor

@HaasCM HaasCM commented Apr 5, 2025

Hey!

Been a lurker for a little bit. But was working on getting this app running on a self hosted Ubuntu server I run on my domain. So created a Dockerfile to run the http server inside of a docker container. It's a little dirty as I just add everything in the whole directory to the container; javascript isn't really my area of expertise.

But thought I'd push it back up to you to see if you'd like it.

I also updated the README with steps on how to use it and run it.

Let me know if you're interested in the changes or if you want any changes made.

Thanks for all of the work you've done so far! Excited to help build out the tool a little more to help out us logi mains.

Comment thread README.md
If you plan to use your GPU(s) for training, you will need to install NVIDIA drivers and the NVIDIA Container Toolkit. [https://docs.nvidia.com/ai-enterprise/deployment/vmware/latest/docker.html]

Build the docker container by running docker `docker build --tag 'fir_trainer' .`
Build the docker container by running docker `docker build -f Dockerfile.trainer --tag 'fir_trainer' .`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't actually test these commands, but can. I'm fairly positive the syntax is correct.

Comment thread README.md
cd fir
python3 -m http.server
```
### Docker
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did test the dockerfile build and run process, as well as the port override functionality.

Copy link
Copy Markdown
Owner

@GICodeWarrior GICodeWarrior left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. 🙂

I'm not sure of the advantage of inserting Docker (for this or for training), but I'm nominally OK with adding it.

For the "server" image, maybe consider using the (much smaller) busybox image.

Here's an example:

FROM busybox:1.35

# Create a non-root user to own the files and run our server
RUN adduser -D static
USER static
WORKDIR /home/static

# Copy the static website
# Use the .dockerignore file to control what ends up inside the image!
COPY . .

# Run BusyBox httpd
CMD ["busybox", "httpd", "-f", "-v", "-p", "3000"]

Source: https://lipanski.com/posts/smallest-docker-image-static-website
(for security reasons though, please don't use one of the bespoke images)

If you want a more lean set of files to copy, you should only need foxhole, includes, index.html, favicon.ico, and LICENSE.

Regarding the "trainer" image instructions, your changes look OK. I haven't used that image myself.

@HaasCM
Copy link
Copy Markdown
Contributor Author

HaasCM commented Apr 5, 2025

Thanks for the contribution. 🙂

I'm not sure of the advantage of inserting Docker (for this or for training), but I'm nominally OK with adding it.

For the "server" image, maybe consider using the (much smaller) busybox image.

Here's an example:

FROM busybox:1.35

# Create a non-root user to own the files and run our server
RUN adduser -D static
USER static
WORKDIR /home/static

# Copy the static website
# Use the .dockerignore file to control what ends up inside the image!
COPY . .

# Run BusyBox httpd
CMD ["busybox", "httpd", "-f", "-v", "-p", "3000"]

Source: https://lipanski.com/posts/smallest-docker-image-static-website (for security reasons though, please don't use one of the bespoke images)

If you want a more lean set of files to copy, you should only need foxhole, includes, index.html, favicon.ico, and LICENSE.

Regarding the "trainer" image instructions, your changes look OK. I haven't used that image myself.

Cool! 100% aligned with using the busybox image. Smaller footprint the better. I'll clean things up and fire the PR back once cleaned up.

For some context, I'm actually standing this up alongside some traefik (I believe nginx will do the same thing) instance so you can hit the same FQDN, but it'll route you to different docker containers based on the path of the URL.

I can test the trainer image prior to firing this back over to you.

@GICodeWarrior
Copy link
Copy Markdown
Owner

so you can hit the same FQDN, but it'll route you to different docker containers based on the path of the URL.

Note that the domain name is a security perimeter. So running multiple apps on one domain name (i.e. inside a shared perimeter) has some security implications.
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

I can test the trainer image prior to firing this back over to you.

To complete a training run requires a bunch of content exported from the game assets (via FModel) and (optionally) a directory of the desired icon mods. There is a thread on the LOGI discord with more details if you're interested.

I'm happy to have more folks familiar with how to run the training, and at the same time, that's not a prerequisite for this PR.

@HaasCM HaasCM force-pushed the haascm/add-dockerized-server branch from 0691492 to 413b8a8 Compare April 20, 2025 23:48
Added the build steps and run command to run the HTTP server
from a docker container. At the same time updated the existing
Dockerfile to not conflict with the added Dockerfile.
@HaasCM HaasCM force-pushed the haascm/add-dockerized-server branch from 413b8a8 to 0c337b0 Compare April 20, 2025 23:55
@HaasCM
Copy link
Copy Markdown
Contributor Author

HaasCM commented Apr 20, 2025

I went ahead and updated the docker container to use busybox's certified image at version 1.37.

Copy link
Copy Markdown
Owner

@GICodeWarrior GICodeWarrior left a comment

Choose a reason for hiding this comment

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

Thanks :-)

Comment thread Dockerfile.server Outdated
Comment on lines +22 to +29
# Busybox's httpd doesn't support a mime type for .mjs
# files by default, so we'll need to add it to httpd.conf
# manually. The http daemon also treats .js files as
# application/javascript by default. However, in
# RFC 9239 application/javascript has been marked as
# obselete in favor of text/javascript. So we're overriding
# that mime type as well.
RUN printf ".mjs:text/javascript\n.js:text/javascript\n" > httpd.conf
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

🎉

@GICodeWarrior GICodeWarrior merged commit dfab6c8 into GICodeWarrior:main Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants