Files
spacedrive/apps/server/docker/Dockerfile
Brendan Allan af85ca95e9 [ENG-927, ENG-735, ENG-766] Fix Updater & Tauri 1.5 (#1361)
* custom updater with toasts

* new state management + updated router route

* tauri-specific update route

* ref

* update in prod only

* change 'Install' to 'Update'

* fix tsconfig

* desktop tauri

* remove tauri patch

* tauri 1.5

* tauri 1.5

* use tauri script

* native-deps

* Rework preprep and tauri script to better support tauri 1.5

* Update to tauri 1.5.1
 - Update workspace and apps/desktop dependencies
 - Fix mustache import, @types/mustache is not compatible with ES imports
 - Replace arm64 with aarch64 in machineID, they should be treated the same and this simplyfies the code

* Fix tauri updater not building due to missing key
 - Fix dmg background not being found
 - Generate an adhoc key for tauri updater with it is enabled and the user is doing a prod build

* Fix ctrl+c/ctrl+v typo

* Normalie @tanstack/react-query version through workspace
 - Use undici in scripts instead of global fetch
 - Fix typecheck

* Fix linux prod and dev builds
 - Improve error handling in tauri.mjs

* Normalize dev deps in workspace
 - Improve linux shared libs setup

* Fix CI and server docker

* Fix windows
 - Remove superfluous envvar

* Attempt to fix server, mobile, deb and release updater

* Attempt to fix deb and mobile again
 - Fix type on deb dependency
 - Enable release deb for aarch64-unknown-linux-gnu

* Github doesn't have arm runners
 - Fix typo in server Dockerfile

* Publish deb and updater artifacts

* remove version from asset name

* update commands

* log release

* Some logs on updater errors

* show updater errors on frontend

* fix desktop ui caching

---------

Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com>
Co-authored-by: Ericson Fogo Soares <ericson.ds999@gmail.com>
2023-10-10 07:30:56 +00:00

114 lines
2.9 KiB
Docker

ARG REPO=spacedriveapp/spacedrive
ARG REPO_REF=main
ARG DEBIAN_FRONTEND=noninteractive
#--
FROM debian:bookworm as base
ARG DEBIAN_FRONTEND
ADD https://gist.githubusercontent.com/HeavenVolkoff/ff7b77b9087f956b8df944772e93c071/raw \
/etc/apt/apt.conf.d/99docker-apt-config
RUN rm -f /etc/apt/apt.conf.d/docker-clean; \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get update && apt-get upgrade
#--
FROM base as build-base
ARG DEBIAN_FRONTEND
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get install build-essential git sudo unzip wget
RUN wget -qO- https://get.pnpm.io/install.sh | env SHELL=bash PNPM_HOME=/usr/share/pnpm sh -
ENV PNPM_HOME="/usr/share/pnpm" \
PATH="/usr/share/pnpm:$PATH"
RUN pnpm env use --global latest
WORKDIR /srv
ARG REPO REPO_REF
RUN git init spacedrive
RUN git -C spacedrive remote add origin "https://github.com/${REPO}.git"
RUN git -C spacedrive fetch --depth=1 origin "$REPO_REF"
RUN git -C spacedrive config advice.detachedHead false
RUN git -C spacedrive checkout FETCH_HEAD
WORKDIR /srv/spacedrive
#--
FROM build-base as web
# Run pnpm install with docker cache
RUN --mount=type=cache,target=/root/.local/share/pnpm/store --mount=type=cache,target=/root/.cache/pnpm/metadata \
pnpm install --frozen-lockfile
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN pnpm web build
#--
FROM build-base as server
RUN wget -qO- https://sh.rustup.rs | sh -s -- -yq --profile minimal
ENV PATH="/root/.cargo/bin:$PATH"
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
env CI=true ./scripts/setup.sh
RUN cd ./scripts; npm i --production
RUN --mount=type=cache,target=/root/.cache/prisma/binaries/cli/ \
pnpm prep
COPY --from=web /srv/spacedrive/apps/web/dist /srv/spacedrive/apps/web/dist
RUN cargo build --features assets --release -p sd-server
#--
FROM base
ENV TZ=UTC \
PUID=1000 \
PGID=1000 \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
TMPDIR=/tmp \
LANGUAGE=en \
DATA_DIR=/data
# Note: This needs to happen before the apt call to avoid locking issues with the previous step
COPY --from=server /srv/spacedrive/target/release/sd-server /usr/bin/
COPY --from=server /srv/spacedrive/apps/.deps/lib /usr/lib/spacedrive
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get install \
libavdevice59 libpostproc56 libswscale6 libswresample4 libavformat59 libavutil57 libavfilter8 \
libavcodec59
COPY --chmod=755 entrypoint.sh /usr/bin/
# Expose webserver
EXPOSE 8080
# Create the data directory to store the database
VOLUME [ "/data" ]
# Run the CLI when the container is started
ENTRYPOINT [ "sd-server" ]
LABEL org.opencontainers.image.title="Spacedrive Server" \
org.opencontainers.image.source="https://github.com/spacedriveapp/spacedrive"