Closed M4RC02U1F4A4 closed 4 years ago
Here's a hacked-together dockerfile that could be used as a base. One improvement I'd probably make would be to do the builds outside of the container, so the build tools aren't included in the final image.
Some important notes:
docker run -itd --name mongo -p 127.0.0.1:27017:27017/tcp -p 127.0.0.1:27018:27018/tcp mongo
FROM alpine:latest
USER 0
COPY --from=node:alpine /usr/local/lib/node_modules /usr/local/lib/node_modules
COPY --from=node:alpine /usr/local/bin/node /usr/local/bin/node
# Setup node
RUN apk add --no-cache libstdc++ && \
export NODE_PATH=/usr/local/lib/node_modules && \
ln -s $NODE_PATH/npm/bin/npm-cli.js /usr/local/bin/npm && \
ln -s $NODE_PATH/npm/bin/npx-cli.js /usr/local/bin/npx
# Fetch required packages... Instead of doing this, we could build locally and 'COPY' into the image, skipping the remaining 'RUN' build steps
RUN apk add --no-cache git make build-base python2 ffmpeg
# Fetch youtube-dl-react-viewer v1.0.0 from github
RUN cd /opt && \
mkdir youtube-dl-react-viewer && \
cd youtube-dl-react-viewer && \
git clone https://github.com/graham-walker/youtube-dl-react-viewer . && \
git checkout tags/v1.0.0
WORKDIR /opt/youtube-dl-react-viewer/youtube-dl-express-backend
# Fetch youtube-dl-react-viewer dependencies
RUN cp .env.sample .env && \
npm install --unsafe-perm
RUN cd ../youtube-dl-react-frontend && \
npm install --unsafe-perm
# Build frontend
RUN cd ../youtube-dl-react-frontend && \
cp .env.sample .env && \
npm run build
EXPOSE 5000/tcp
HEALTHCHECK \
--start-period=10s --interval=30s --timeout=2s --retries=3 \
CMD nc -zv 127.0.0.1:5000
ENTRYPOINT ["node", "--require", "dotenv/config", "index.js"]
Edit: Just noticed I forgot to include ffmpeg... 🤦
Any plan to make a docker version?