-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
108 lines (90 loc) · 2.77 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
FROM ubuntu:22.04
# Set specific dependency versions
ARG NODEJS_VERSION=22.12.0
ARG NPM_VERSION=10.9.0
ARG REDIS_VERSION=7.0.15
ARG POCKETBASE_VERSION=0.23.7
ARG YTDLP_VERSION=2024.12.06
ARG PM2_VERSION=5.3.0
ARG FFMPEG_VERSION=6.1.1-3
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
# Disable IPv6
RUN echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf \
&& echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf \
&& sysctl -p
# Install required system dependencies
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
ca-certificates \
gnupg \
software-properties-common \
logrotate \
unzip \
ffmpeg
# Install NodeJS, pnpm, and pm2
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash && \
export NVM_DIR="/root/.nvm" && \
. "$NVM_DIR/nvm.sh" && \
nvm install ${NODEJS_VERSION} && \
nvm use ${NODEJS_VERSION} && \
nvm alias default ${NODEJS_VERSION} && \
npm install -g pnpm pm2
# Install Redis
RUN apt-get update && apt-get install -y redis-server
# Install yt-dlp
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/download/${YTDLP_VERSION}/yt-dlp -o /usr/local/bin/yt-dlp \
&& chmod a+rx /usr/local/bin/yt-dlp
# Download specific Pocketbase version
RUN wget https://github.com/pocketbase/pocketbase/releases/download/v${POCKETBASE_VERSION}/pocketbase_${POCKETBASE_VERSION}_linux_amd64.zip -O /tmp/pocketbase.zip \
&& unzip /tmp/pocketbase.zip -d /db/ \
&& rm /tmp/pocketbase.zip
# Create required directories
RUN mkdir -p /db /config /config/logs
# Configure logrotate for ytarr logs
RUN printf "/config/logs/ytarr.txt {\n\
daily\n\
rotate 7\n\
compress\n\
delaycompress\n\
missingok\n\
notifempty\n\
}" > /etc/logrotate.d/ytarr
# Copy application files
COPY . /app
# Set working directory
WORKDIR /app
# Move pocketbase migrations
RUN mv pb_migrations /db/
RUN export NVM_DIR="/root/.nvm" && \
. "$NVM_DIR/nvm.sh" && \
pnpm run ui:build
RUN export NVM_DIR="/root/.nvm" && \
. "$NVM_DIR/nvm.sh" && \
pnpm run cron:build
# Prepare startup script
RUN echo '#!/bin/bash\n\
export NVM_DIR="/root/.nvm"\n\
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"\n\
\n\
# Create necessary directories if not already present\n\
mkdir -p /config /config/logs /db\n\
\n\
# Initialize default config file if not present\n\
if [ ! -f /config/config.json ]; then\n\
printf "{\"settings\":{\"initialized\":false,\"version\":\"0.0.1\"}}" > /config/config.json\n\
fi\n\
\n\
# Start services using PM2 configuration file\n\
pm2 start /app/pm2.config.json\n\
\n\
# Keep container running\n\
pm2 logs' > /start.sh \
&& chmod +x /start.sh
# Expose necessary ports
EXPOSE 8020
EXPOSE 8030
# Set entrypoint
ENTRYPOINT ["/start.sh"]