Files
spacedrive/apps/server/docker/Dockerfile
Vítor Vasconcellos f7277d602f Frontend misc fixes and deps update (#1650)
Dependencies overhaul
 - Update dependencies for all projects (except Mobile-only deps)
 - Remove unused dependencies from all projects (except Mobile-only deps)
 - Fix Storybook failing to import sd/ui style
 - Add Node 21 as not supported due to sass-loader not working on it yet
 - Add work-around for new rook version requiring webpack specific global property
 - Fix landing dev not working due to missing default env value on dev
 - Fix some incorrect uses of phosphor-icons non server side icons on server components on landing
 - Fix some incorrect uses of phosphor-icons server side icon on client components on landing
 - Fix landing fail to build on dev due to always required a Github Token to get the latest release
 - Fix new Next.js version not suporting Response.redirect due to immutable Headers
 - Add Gitlab as social link for teams page
 - Update Vítor's team photo
 - Add Vítor's twitter link
 - Fix some warning due to missing useEffect dependencies
 - Remove test-files dir
 - Fix QuickPreview unblurred buttons in Linux
 - Formatting
2023-10-24 07:51:58 +00:00

110 lines
2.8 KiB
Docker

ARG REPO=spacedriveapp/spacedrive
ARG REPO_REF=main
#--
FROM debian:bookworm as base
ADD https://gist.githubusercontent.com/HeavenVolkoff/ff7b77b9087f956b8df944772e93c071/raw \
/etc/apt/apt.conf.d/99docker-apt-config
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN rm -f /etc/apt/apt.conf.d/docker-clean
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
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"