mirror of
https://github.com/tursodatabase/libsql.git
synced 2024-12-15 16:49:47 +00:00
73 lines
2.4 KiB
Docker
73 lines
2.4 KiB
Docker
# build sqld
|
|
FROM rust:slim-bullseye as builder
|
|
RUN apt update \
|
|
&& apt install -y libclang-dev clang \
|
|
build-essential tcl protobuf-compiler file \
|
|
libssl-dev pkg-config git cmake \
|
|
&& apt clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /sqld
|
|
COPY . .
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
--mount=type=cache,target=/usr/local/cargo/git \
|
|
--mount=type=cache,target=/sqld/target \
|
|
cargo build -p libsql-server --release && \
|
|
cp target/release/sqld /sqld/bin
|
|
|
|
|
|
# official gosu install instruction (https://github.com/tianon/gosu/blob/master/INSTALL.md)
|
|
FROM debian:bullseye-slim as gosu
|
|
ENV GOSU_VERSION 1.17
|
|
RUN set -eux; \
|
|
# save list of currently installed packages for later so we can clean up
|
|
savedAptMark="$(apt-mark showmanual)"; \
|
|
apt-get update; \
|
|
apt-get install -y --no-install-recommends ca-certificates gnupg wget; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
\
|
|
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
|
|
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
|
|
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
|
|
\
|
|
# verify the signature
|
|
export GNUPGHOME="$(mktemp -d)"; \
|
|
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
|
|
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
|
|
gpgconf --kill all; \
|
|
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
|
|
\
|
|
# clean up fetch dependencies
|
|
apt-mark auto '.*' > /dev/null; \
|
|
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
|
|
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
|
|
\
|
|
chmod +x /usr/local/bin/gosu; \
|
|
# verify that the binary works
|
|
gosu --version; \
|
|
gosu nobody true
|
|
|
|
# runtime
|
|
FROM debian:bullseye-slim
|
|
RUN apt update
|
|
|
|
EXPOSE 5001 8080
|
|
VOLUME [ "/var/lib/sqld" ]
|
|
|
|
RUN groupadd --system --gid 666 sqld
|
|
RUN adduser --system --home /var/lib/sqld --uid 666 --gid 666 sqld
|
|
WORKDIR /var/lib/sqld
|
|
USER sqld
|
|
|
|
COPY docker-entrypoint.sh /usr/local/bin
|
|
COPY docker-wrapper.sh /usr/local/bin
|
|
|
|
COPY --from=gosu /usr/local/bin/gosu /usr/local/bin/gosu
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
COPY --from=builder /sqld/bin /bin/sqld
|
|
|
|
USER root
|
|
|
|
ENTRYPOINT ["/usr/local/bin/docker-wrapper.sh"]
|
|
CMD ["/bin/sqld"]
|