Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ go.work.sum
result
*.wasm
/all_plugins
/worker
76 changes: 32 additions & 44 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,39 @@
FROM nixos/nix:latest AS builder

# Copy our source and setup our working dir.
COPY . /tmp/build
WORKDIR /tmp/build

# Build our Nix environment
RUN nix \
--extra-experimental-features "nix-command flakes" \
--option filter-syscalls false \
--option max-jobs auto \
build .#server && \
mv /tmp/build/result /tmp/build/server

RUN nix \
--extra-experimental-features "nix-command flakes" \
--option filter-syscalls false \
--option max-jobs auto \
build .#cli && \
mv /tmp/build/result /tmp/build/cli

RUN nix \
--extra-experimental-features "nix-command flakes" \
--option filter-syscalls false \
--option max-jobs auto \
build .#allPlugins && \
mv /tmp/build/result /tmp/build/allPlugins

# Copy the Nix store closure into a directory. The Nix store closure is the
# entire set of Nix store values that we need for our build.
RUN mkdir /tmp/nix-store-closure
RUN cp -R $(nix-store -qR server/) /tmp/nix-store-closure
RUN cp -R $(nix-store -qR cli/) /tmp/nix-store-closure
RUN cp -R $(nix-store -qR allPlugins/) /tmp/nix-store-closure


FROM alpine:latest
FROM golang:1.26-bookworm as builder

ENV CGO_LDFLAGS="-lassuan -lgpg-error"
RUN apt-get update && \
apt-get install -y build-essential xz-utils libgpgme-dev libbtrfs-dev libassuan-dev libgpg-error0 && \
curl https://wasmtime.dev/install.sh -sSf | bash

WORKDIR /build
COPY ./go.mod ./go.sum .
RUN go mod download

ENV CGO_ENABLED=1

COPY --parents ./nats.go ./embed.go ./logo.webp ./README.md ./cmd ./executor ./lua ./plugins ./script ./store ./templates .
RUN go build ./cmd/cli && \
go build ./cmd/server && \
go build -tags "wasmtime podman" ./cmd/worker && \
go build -buildmode=plugin -o db.so ./plugins/db && \
go build -buildmode=plugin -o gopher-lua-libs.so ./plugins/gopher-lua-libs && \
go build -buildmode=plugin -o hello.so ./plugins/hello && \
go build -buildmode=plugin -o httpscrape.so ./plugins/httpscrape && \
go build -buildmode=plugin -o vault.so ./plugins/vault

FROM debian:bookworm-slim

RUN curl https://wasmtime.dev/install.sh -sSf | bash

WORKDIR /app

RUN mkdir -p /app/plugins
COPY ./docker/entrypoint.sh /entrypoint.sh
RUN mkdir -p /app/share/plugins && chmod +x /entrypoint.sh

COPY --from=builder /tmp/nix-store-closure /nix/store
COPY --from=builder /tmp/build/server /app
COPY --from=builder /tmp/build/cli /app
COPY --from=builder /tmp/build/allPlugins/*.so /app/share/plugins/
RUN mv /app/bin/msgscript /app/bin/server && mv /app/bin/msgscriptcli /app/bin/cli
COPY --from=builder /build/cli /app/cli
COPY --from=builder /build/server /app/server
COPY --from=builder /build/worker /app/worker
COPY --from=builder /build/*.so /app/plugins/
RUN chmod +x /entrypoint.sh

EXPOSE 7643

Expand Down
Loading
Loading