szabodanika / microbin

A secure, configurable file-sharing and URL shortening web app written in Rust.
https://microbin.eu
BSD 3-Clause "New" or "Revised" License
2.65k stars 163 forks source link

Docker Image #9

Closed ItsNoted closed 1 year ago

ItsNoted commented 2 years ago

Will there be an official Docker image?

szabodanika commented 2 years ago

There isn't one yet but I'd be more than happy to add one, I don't see why not. I will look into it soon, it should be fairly simple to set it up as well.

aazam476 commented 2 years ago

I have forked the repo, and am trying to make a local docker image. If that is fine with @szabodanika, can I make a pull request once I am done?

morganzero commented 2 years ago

I'd love a dockerized version of this!

szabodanika commented 2 years ago

I have a Dockerfile draft on my PC - I will share this as soon as I get home from work. I'm not sure how I will make the docker images though, I really want platform independent images but they look quite hard to make. Maybe for now it'll be easier to add the Dockerfile and instructions for how to set it up or perhaps a bash script that does that automatically, and maybe a simple Linux/x86 image, most people would need that one anyways I assume.

szabodanika commented 2 years ago

This is what I came up with, what do you think?

@AzamServer, were you thinking of something like this?

It works fine on my M1 Mac:

# latest rust will be used to build the binary
FROM rust:latest as builder

# the temporary directory where we build
WORKDIR /usr/src/microbin

# copy sources to /usr/src/microbin on the temporary container
COPY . .

# run release build
RUN cargo build --release

# create final container using slim version of debian
FROM debian:buster-slim

# microbin will be in /usr/local/bin/microbin/
WORKDIR /usr/local/bin

# copy built exacutable
COPY --from=builder /usr/src/microbin/target/release/microbin /usr/local/bin/microbin

# copy /static folder containing the stylesheets
COPY --from=builder /usr/src/microbin/static /usr/local/bin/static

# run the binary
CMD ["microbin"]
aazam476 commented 2 years ago

I made one where I would keep the Rust parent image, and not change to a bare Debian image, but yours would work better, as it would have a smaller image size.

szabodanika commented 1 year ago

I merged #49 and successfully ran the workflow, images are available at https://hub.docker.com/repository/docker/danielszabo99/microbin and each new tag should be automatically appear on DockerHub in an hour or so. You guys can give it a try, hopefully it works fine on both arm and x86.

szabodanika commented 1 year ago

Please use #23 for any further discussion on this