mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-09-03 23:52:05 +00:00
Merge remote-tracking branch 'enko/feature/reduced-container-size'
This commit is contained in:
commit
196fafa2e5
41
Dockerfile
41
Dockerfile
@ -1,47 +1,44 @@
|
|||||||
FROM node:10.16.0-alpine
|
FROM node:12.16.1-alpine AS builder
|
||||||
|
|
||||||
LABEL maintainer="Andreas Peters <support@aventer.biz>"
|
LABEL maintainer="Andreas Peters <support@aventer.biz>"
|
||||||
#Upstream URL: https://git.aventer.biz/AVENTER/docker-matrix-dimension
|
#Upstream URL: https://git.aventer.biz/AVENTER/docker-matrix-dimension
|
||||||
|
|
||||||
RUN apk add dos2unix --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ --allow-untrusted
|
WORKDIR /home/node/matrix-dimension
|
||||||
|
|
||||||
RUN apk update && \
|
RUN mkdir -p /home/node/matrix-dimension
|
||||||
apk add --no-cache bash gcc python make g++ sqlite && \
|
|
||||||
mkdir /home/node/.npm-global && \
|
|
||||||
mkdir -p /home/node/app
|
|
||||||
|
|
||||||
COPY ./docker-entrypoint.sh /
|
|
||||||
COPY . /home/node/matrix-dimension
|
COPY . /home/node/matrix-dimension
|
||||||
|
|
||||||
|
RUN chown -R node /home/node/matrix-dimension
|
||||||
RUN chown -R node:node /home/node/app && \
|
|
||||||
chown -R node:node /home/node/.npm-global && \
|
|
||||||
chown -R node:node /home/node/matrix-dimension
|
|
||||||
|
|
||||||
USER node
|
USER node
|
||||||
|
|
||||||
ENV PATH=/home/node/.npm-global/bin:$PATH
|
RUN npm clean-install && \
|
||||||
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
|
node /home/node/matrix-dimension/scripts/convert-newlines.js /home/node/matrix-dimension/docker-entrypoint.sh && \
|
||||||
|
NODE_ENV=production npm run-script build
|
||||||
|
|
||||||
RUN cd /home/node/matrix-dimension && \
|
FROM node:12.16.1-alpine
|
||||||
npm install -D wd rimraf webpack webpack-command sqlite3 pg pg-hstore && \
|
|
||||||
NODE_ENV=production npm run-script build:web && npm run-script build:app
|
|
||||||
|
|
||||||
USER root
|
WORKDIR /home/node/matrix-dimension
|
||||||
|
|
||||||
RUN apk del gcc make g++ && \
|
COPY --from=builder /home/node/matrix-dimension/docker-entrypoint.sh /
|
||||||
rm /home/node/matrix-dimension/Dockerfile && \
|
|
||||||
rm /home/node/matrix-dimension/docker-entrypoint.sh && \
|
COPY --from=builder /home/node/matrix-dimension/build /home/node/matrix-dimension/build
|
||||||
dos2unix /docker-entrypoint.sh
|
COPY --from=builder /home/node/matrix-dimension/package* /home/node/matrix-dimension/
|
||||||
|
COPY --from=builder /home/node/matrix-dimension/config /home/node/matrix-dimension/config
|
||||||
|
|
||||||
|
RUN chown -R node /home/node/matrix-dimension
|
||||||
|
|
||||||
USER node
|
USER node
|
||||||
|
|
||||||
|
RUN npm clean-install --production
|
||||||
|
|
||||||
VOLUME ["/data"]
|
VOLUME ["/data"]
|
||||||
|
|
||||||
# Ensure the database doesn't get lost to the container
|
# Ensure the database doesn't get lost to the container
|
||||||
ENV DIMENSION_DB_PATH=/data/dimension.db
|
ENV DIMENSION_DB_PATH=/data/dimension.db
|
||||||
|
|
||||||
EXPOSE 8184
|
EXPOSE 8184
|
||||||
#CMD ["/bin/sh"]
|
# CMD ["/bin/sh"]
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
set -e
|
|
||||||
|
|
||||||
cd /home/node/matrix-dimension/
|
|
||||||
|
|
||||||
if [ -f "/data/config.yaml" ]; then
|
if [ -f "/data/config.yaml" ]; then
|
||||||
cp /data/config.yaml /home/node/matrix-dimension/config/production.yaml
|
cp /data/config.yaml /home/node/matrix-dimension/config/production.yaml
|
||||||
|
23
scripts/convert-newlines.js
Normal file
23
scripts/convert-newlines.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
|
(async function () {
|
||||||
|
if (process.argv.length !== 3) {
|
||||||
|
console.error('Wrong number of arguments');
|
||||||
|
process.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const filePath = process.argv.pop();
|
||||||
|
|
||||||
|
const fileExists = await util.promisify(fs.exists)(filePath);
|
||||||
|
|
||||||
|
if (fileExists) {
|
||||||
|
const file = await fs.promises.readFile(filePath, { encoding: 'utf-8' });
|
||||||
|
await fs.promises.writeFile(
|
||||||
|
filePath,
|
||||||
|
file
|
||||||
|
.replace(/\r\n/g, '\n')
|
||||||
|
.replace(/\r/, '\n'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})();
|
Loading…
Reference in New Issue
Block a user