Naouak / marvel-lcg-randomizer

32 stars 15 forks source link

Suggestion: Docker Support #87

Open Shomzyka opened 1 month ago

Shomzyka commented 1 month ago

Hello,

First off, I want to say that I love this project! I’ve recently started using it to randomize my playthroughs, and it’s been fantastic.

I’ve been running a home lab server for about a year now and have several apps running locally. Since I noticed this project didn’t have Docker support, I decided to test it out myself, and to my surprise, it worked! (A surprise because it was my first time setting something like this up.)

I’ve opened up a repository where I pushed the Dockerfile, but it would make more sense for it to be part of your project. The Dockerfile pulls the latest version from your repository—it may not be the perfect solution, but it requires no maintenance.

https://github.com/Shomzyka/marvel-randomizer-docker

I’d love to hear your thoughts on this. If you prefer not to have it hosted in my repo, I’m happy to transfer everything over to yours.

Let me know what you think!

Naouak commented 1 month ago

I can add a Dockerfile to the project. It shouldn't be very complicated to have a multistage Dockerfile. You can use the branch gh-pages to get directly the built version and remove the node requirement : https://github.com/Naouak/marvel-lcg-randomizer/tree/gh-pages

Shomzyka commented 1 month ago

Perfect, good idea, I will clone the gh-pages branch into the Nginx container.

Let me test this out and update the Dockerfile.

Shomzyka commented 1 month ago

I've managed to make it work, but not sure if it's the right approach i had to make a workaround since the index.html refers to the paths that are not by structure, so I had to move files around after cloning the repo.

# Use the official Nginx image as the base
FROM nginx:alpine

# Install Git to clone the repository
RUN apk add --no-cache git

# Set the working directory to the folder where Nginx serves static files
WORKDIR /usr/share/nginx/html

# Remove the default Nginx static assets
RUN rm -rf ./*

# Clone the 'gh-pages' branch of the repository into the Nginx folder
RUN git clone --branch gh-pages https://github.com/Naouak/marvel-lcg-randomizer.git .

# Create the necessary directories for the application
RUN mkdir -p marvel-lcg-randomizer/js marvel-lcg-randomizer/css marvel-lcg-randomizer/img marvel-lcg-randomizer/fonts

# Move files to the appropriate directory
RUN mv js/* marvel-lcg-randomizer/js/ && \
    mv css/* marvel-lcg-randomizer/css/ && \
    mv img/* marvel-lcg-randomizer/img/ && \
    mv fonts/* marvel-lcg-randomizer/fonts/

# Expose port 80 for the web server
EXPOSE 80