Skip to content

Make a statically linked build #17

@eternal-flame-AD

Description

@eternal-flame-AD

Currently none of the official builds will work on Alpine, we should have a statically linked build. sqlite3 is public domain so I don't think there should be non-technical complications, something like this (and changing the server build script to append not overwrite LD_FLAGS) should work.

ARG GO_VERSION
FROM gotify/build:$GO_VERSION-linux-amd64
ARG VCS_REF
RUN \
  apt-get update && \
  apt-get install -y musl-tools

ENV CGO_ENABLED=1
ENV GOOS=linux
ENV GOARCH=amd64
ENV LD_FLAGS="-linkmode external -extldflags '-static'"
ENV CC=musl-gcc

LABEL org.opencontainers.image.source="https://github.com/gotify/build" \
  org.opencontainers.image.revision=$VCS_REF 

However since there are no system libc dependencies here or plugin compatibility issues (it's not a dynamically linked system so no plugins), another options is to simply don't use docker at all and build a strictly statically linked binary straight from GH Actions, but out of consistency I think going with docker is good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions