Alt. Dockerfile #738

Open
opened 2024-03-27 04:13:52 +00:00 by IngwiePhoenix · 3 comments

Hey!

Wrote this mainly for selfhosting Snort on my own instance. But, I thought I'd share it.

FROM alpine:3.19 AS make-snort
RUN apk add nodejs npm git \
    && npm i -g yarn \
    && mkdir -p /opt/src \
    && git clone \
         --depth 1 --single-branch -b main \
         https://git.v0l.io/Kieran/snort.git \
         /opt/src \
    && cd /opt/src \
    && yarn --network-timeout 1000000 \
    && yarn build

FROM alpine:3.19 AS make-dufs
RUN apk add wget \
    && wget https://github.com/sigoden/dufs/releases/download/v0.40.0/dufs-v0.40.0-$(uname -m)-unknown-linux-musl.tar.gz \
    && tar xvfz dufs*.tar.gz \
    && mv dufs /usr/bin/dufs

FROM alpine:3.19 AS final
RUN mkdir /www
WORKDIR /www
COPY --from=make-snort /opt/src/packages/app/build /www
COPY --from=make-dufs /usr/bin/dufs /usr/bin/dufs
CMD ["/usr/bin/dufs", "--render-spa", "--bind", "0.0.0.0", "/www"]

Technically, final could also be a Busybox-based container - but I wasn't sure if that one ran on musl or not (which is what the prebuilt dufs is built against on Linux). The behaviour can be customized with ENV vars, as found in dufs' docs

Kind regards,
Ingwie

Hey! Wrote this mainly for selfhosting Snort on my own instance. But, I thought I'd share it. ```Dockerfile FROM alpine:3.19 AS make-snort RUN apk add nodejs npm git \ && npm i -g yarn \ && mkdir -p /opt/src \ && git clone \ --depth 1 --single-branch -b main \ https://git.v0l.io/Kieran/snort.git \ /opt/src \ && cd /opt/src \ && yarn --network-timeout 1000000 \ && yarn build FROM alpine:3.19 AS make-dufs RUN apk add wget \ && wget https://github.com/sigoden/dufs/releases/download/v0.40.0/dufs-v0.40.0-$(uname -m)-unknown-linux-musl.tar.gz \ && tar xvfz dufs*.tar.gz \ && mv dufs /usr/bin/dufs FROM alpine:3.19 AS final RUN mkdir /www WORKDIR /www COPY --from=make-snort /opt/src/packages/app/build /www COPY --from=make-dufs /usr/bin/dufs /usr/bin/dufs CMD ["/usr/bin/dufs", "--render-spa", "--bind", "0.0.0.0", "/www"] ``` Technically, `final` could also be a Busybox-based container - but I wasn't sure if that one ran on musl or not (which is what the prebuilt dufs is built against on Linux). The behaviour can be customized with ENV vars, as found [in dufs' docs](https://github.com/sigoden/dufs?tab=readme-ov-file#environment-variables) Kind regards, Ingwie
Owner

Nice, what is dufs, and why use it over nginx?

Nice, what is dufs, and why use it over nginx?
Kieran added the
enhancement
label 2024-04-12 10:00:42 +00:00
Author

Most people running Docker containers will already have established an outgoing Reverse Proxy. dufs really only does one thing and that very, very well: serve static files, and it even has an SPA fallback where anyunknown URL will just render the index.html, as you would expect. The idea is, that since most people put it behind a revproxy anyway, might as well slim down the backend.

Hence, dufs. :)

Also, sorry for the late reply, never got an email notification about your reply...

Most people running Docker containers will already have established an outgoing Reverse Proxy. `dufs` really only does one thing and that very, very well: serve static files, and it even has an SPA fallback where anyunknown URL will just render the `index.html`, as you would expect. The idea is, that since most people put it behind a revproxy anyway, might as well slim down the backend. Hence, dufs. :) Also, sorry for the late reply, never got an email notification about your reply...
Owner

Doesn't nginx work well enough for this?

Doesn't nginx work well enough for this?
Kieran added the
question
label 2024-05-27 14:51:13 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Kieran/snort#738
No description provided.