mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-03-30 11:00:13 +00:00
* Use multi-stage build in Dockerfile https://github.com/the-draupnir-project/Draupnir/issues/300. * Move git describe and build into one stage. Probably won't be a good idea to download an alpine image just to install git. * Remove git describe step from CI. * whoopsie, copy version from the build stage not the deleted stamp.
30 lines
1017 B
Docker
30 lines
1017 B
Docker
# Copyright 2024 Gnuxie <Gnuxie@protonmail.com>
|
|
# Copyright 2019 The Matrix.org Foundation C.I.C.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0 AND AFL-3.0
|
|
|
|
FROM node:20-slim as build-stage
|
|
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
|
COPY . /tmp/src
|
|
# describe the version.
|
|
RUN cd /tmp/src && git describe > version.txt.tmp && mv version.txt.tmp version.txt
|
|
# build and install
|
|
RUN cd /tmp/src \
|
|
&& yarn install --frozen-lockfile --network-timeout 100000 \
|
|
&& yarn build \
|
|
&& yarn install --frozen-lockfile --production --network-timeout 100000
|
|
|
|
FROM node:20-slim as final-stage
|
|
COPY --from=build-stage /tmp/src/version.txt version.txt
|
|
COPY --from=build-stage /tmp/src/lib/ /draupnir/
|
|
COPY --from=build-stage /tmp/src/node_modules /node_modules
|
|
COPY --from=build-stage /tmp/src/draupnir-entrypoint.sh /
|
|
COPY --from=build-stage /tmp/src/package.json /
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NODE_CONFIG_DIR=/data/config
|
|
|
|
CMD ["bot"]
|
|
ENTRYPOINT ["./draupnir-entrypoint.sh"]
|
|
VOLUME ["/data"]
|