Skip to content

Instantly share code, notes, and snippets.

@Izumiko
Created August 10, 2023 12:16
Show Gist options
  • Save Izumiko/ca5a53c31f1425783bdc7af6b18eeab1 to your computer and use it in GitHub Desktop.
Save Izumiko/ca5a53c31f1425783bdc7af6b18eeab1 to your computer and use it in GitHub Desktop.
Dockerfile for NasCab
FROM alpine:3.18 AS BUILD_IMAGE
# Change repository to aliyun
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# Install dependencies
RUN apk update && apk upgrade && \
apk add --no-cache nodejs npm python3 curl && \
apk add --no-cache --virtual build-dependencies gcc g++ make cmake gfortran libffi-dev openssl-dev libtool && \
apk add --no-cache vips-heif vips-tools vips-cpp vips-dev && \
apk add --no-cache ffmpeg && \
rm -rf /var/cache/apk/*
# Install bytenode
RUN npm install -g bytenode
# Install node-prune
RUN curl -sf https://gobinaries.com/tj/node-prune | PREFIX=/usr/local/bin sh
# Working directory
WORKDIR /nascab
# Copy source code
COPY ./appRaw/ ./appRaw/
COPY ./app/ ./app/
COPY ./certs/ ./certs/
COPY ./public/ ./public/
COPY ./public_pdf/ ./public_pdf/
COPY ./database/ ./database/
COPY ./libs/256x256.png ./libs/256x256.png
COPY ./libs/logo-tray.png ./libs/logo-tray.png
COPY ./libs/logo.png ./libs/logo.png
COPY ./libs/transcodetest ./libs/transcodetest
COPY ./bytenodeScripts.js ./bytenodeScripts.js
# Copy package.json
COPY ./package.json .
COPY ./.npmrc .
RUN chmod 777 ./libs
# Install dependencies
RUN npm install
# bytenode compile
RUN node ./bytenodeScripts.js && rm -rf ./bytenodeScripts.js ./package-lock.json
# Prune dev dependencies
RUN npm prune --production
# Prune unused files
RUN /usr/local/bin/node-prune
FROM alpine:3.18
# Install dependencies
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk update && apk upgrade && \
apk add --no-cache python3 && \
apk add --no-cache vips-heif vips-tools vips-cpp vips-dev && \
apk add --no-cache ffmpeg && \
rm -rf /var/cache/apk/* && \
npm install -g bytenode
# Working directory
WORKDIR /nascab
# Copy from build image
COPY --from=BUILD_IMAGE /nascab .
# Expose port
EXPOSE 21
EXPOSE 80
EXPOSE 443
EXPOSE 90
# Volume
VOLUME ["/root/.local/share/nascab"]
# Cmd
CMD ["bytenode", "/nascab/app/main.jsc"]
FROM ypptec/nascab:latest AS SRC_IMAGE
FROM alpine:3.18 AS BUILD_IMAGE
# Change repository to aliyun
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# Install dependencies
RUN apk update && apk upgrade && \
apk add --no-cache nodejs npm python3 curl && \
apk add --no-cache --virtual build-dependencies gcc g++ make cmake gfortran libffi-dev openssl-dev libtool && \
apk add --no-cache vips-heif vips-tools vips-cpp vips-dev && \
apk add --no-cache ffmpeg && \
rm -rf /var/cache/apk/*
# Install node-prune
RUN curl -sf https://gobinaries.com/tj/node-prune | PREFIX=/usr/local/bin sh
# Working directory
WORKDIR /nascab
# Copy source code
COPY --from=SRC_IMAGE /nascab .
# Reinstall dependencies
RUN rm -rf ./node_modules && npm install
# Prune dev dependencies
RUN npm prune --production
# Prune unused files
RUN /usr/local/bin/node-prune
FROM alpine:3.18
# Install dependencies
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk update && apk upgrade && \
apk add --no-cache python3 && \
apk add --no-cache vips-heif vips-tools vips-cpp vips-dev && \
apk add --no-cache ffmpeg && \
rm -rf /var/cache/apk/* && \
npm install -g bytenode
# Working directory
WORKDIR /nascab
# Copy from build image
COPY --from=BUILD_IMAGE /nascab .
# Expose port
EXPOSE 21
EXPOSE 80
EXPOSE 443
EXPOSE 90
# Volume
VOLUME ["/root/.local/share/nascab"]
# Cmd
CMD ["bytenode", "/nascab/app/main.jsc"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment