Skip to content

Commit

Permalink
Merge pull request #124 from Schroedinger-Hat/feature/dockerfile_for_…
Browse files Browse the repository at this point in the history
…one_off_execution

Feature: Refactor Dockerfile to be usable for running youtube-to-anchorfm with a `docker run` command and add some additional fixes and refactors
  • Loading branch information
matevskial authored Sep 19, 2024
2 parents 601d281 + a61448e commit 4f63d5c
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 95 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.mp3
*.jpg
.env
logs

### Node ###
node_modules
Expand Down
48 changes: 31 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
FROM ubuntu:22.04

RUN apt-get update && apt-get install -y sudo
RUN apt-get -y upgrade
RUN apt-get install -y curl
RUN apt-get install -y ca-certificates curl gnupg
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y sudo ca-certificates curl gnupg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

# install node
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update
RUN apt-get install -y nodejs
RUN apt-get install -y python3
RUN apt-get install --reinstall libgtk2.0-0 -y
RUN apt-get install -y libgbm-dev
RUN apt-get install libnss3 libnss3-tools libxss1 libgtk-3-0 -y
# To allow MP3 conversion
RUN apt-get install ffmpeg -y
RUN apt-get update && apt-get install -y nodejs \
python3 \
libgtk2.0-0 \
libgbm-dev \
libnss3 \
libnss3-tools \
libxss1 \
libgtk-3-0 \
ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them
# into this layer.
RUN --mount=type=bind,source=package.json,target=/package.json \
--mount=type=bind,source=package-lock.json,target=/package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci

COPY src /src
COPY package-lock.json /package-lock.json
COPY package.json /package.json
COPY entrypoint.sh /entrypoint.sh
COPY episode.json /episode.json
COPY src src
COPY package-lock.json .
COPY package.json .
COPY entrypoint.sh .
COPY episode.json .

RUN chmod 777 /entrypoint.sh
ENV LC_ALL=en_US.UTF-8
Expand Down
3 changes: 0 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/sh -l

# Guarantee that we are on the same path as our *.js scripts
cd /
npm ci # more suitable for installs from scratch
npm start
74 changes: 72 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"dependencies": {
"puppeteer": "23.2.1",
"youtube-dl-exec": "3.0.7",
"dotenv": "16.4.5"
"dotenv": "16.4.5",
"log4js": "6.9.1"
},
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 4f63d5c

Please sign in to comment.