-
-
Notifications
You must be signed in to change notification settings - Fork 10
Add Docker support and installation instructions #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AD-Archer
wants to merge
2
commits into
derekantrican:master
Choose a base branch
from
AD-Archer:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+211
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Docker ignore file for Subarr | ||
| # Node modules | ||
| node_modules/ | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # Build outputs | ||
| client/build/ | ||
| .env.local | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
|
|
||
| # Database files (should be handled by volumes) | ||
| server/*.db | ||
| server/*.db-journal | ||
| *.db | ||
| *.db-journal | ||
|
|
||
| # OS generated files | ||
| .DS_Store | ||
| .DS_Store? | ||
| ._* | ||
| .Spotlight-V100 | ||
| .Trashes | ||
| ehthumbs.db | ||
| Thumbs.db | ||
|
|
||
| # IDE files | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # Git | ||
| .git/ | ||
| .gitignore | ||
|
|
||
| # Logs | ||
| logs/ | ||
| *.log | ||
|
|
||
| # Runtime data | ||
| pids/ | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
|
|
||
| # Coverage directory used by tools like istanbul | ||
| coverage/ | ||
|
|
||
| # Dependency directories | ||
| node_modules/ | ||
| jspm_packages/ | ||
|
|
||
| # Optional npm cache directory | ||
| .npm | ||
|
|
||
| # Optional REPL history | ||
| .node_repl_history | ||
|
|
||
| # Output of 'npm pack' | ||
| *.tgz | ||
|
|
||
| # Yarn Integrity file | ||
| .yarn-integrity | ||
|
|
||
| # dotenv environment variables file | ||
| .env | ||
|
|
||
| # Docker files (to avoid recursion) | ||
| Dockerfile | ||
| docker-compose.yml | ||
| .dockerignore | ||
|
|
||
| # Documentation | ||
| README.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Multi-stage Dockerfile for Subarr | ||
| FROM node:alpine3.22 AS base | ||
|
|
||
| # Install system dependencies required for better-sqlite3 | ||
| RUN apk add --no-cache \ | ||
| python3 \ | ||
| make \ | ||
| g++ \ | ||
| sqlite-dev \ | ||
| linux-headers | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy package files | ||
| COPY package*.json ./ | ||
| COPY client/package*.json ./client/ | ||
| COPY server/package*.json ./server/ | ||
|
|
||
| # Install dependencies (including dev dependencies for building native modules) | ||
| RUN npm ci | ||
|
|
||
| # Rebuild better-sqlite3 for the current architecture | ||
| RUN npm rebuild better-sqlite3 | ||
|
|
||
| FROM base AS builder | ||
|
|
||
| # Copy source code | ||
| COPY client/ ./client/ | ||
| COPY server/ ./server/ | ||
|
|
||
| # Build the client | ||
| RUN npm --workspace client run build | ||
|
|
||
| FROM node:alpine3.22 AS production | ||
|
|
||
| # Install only runtime dependencies | ||
| RUN apk add --no-cache sqlite | ||
|
|
||
| # Create non-root user for security | ||
| RUN addgroup -g 1001 -S subarr && \ | ||
| adduser -S subarr -u 1001 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy built application from builder stage | ||
| COPY --from=builder --chown=subarr:subarr /app/node_modules ./node_modules | ||
| COPY --from=builder --chown=subarr:subarr /app/client/build ./client/build | ||
| COPY --from=builder --chown=subarr:subarr /app/server ./server | ||
| COPY --from=builder --chown=subarr:subarr /app/package.json ./ | ||
|
|
||
| # Rebuild native module for runtime architecture (avoids Exec format error) | ||
| RUN apk add --no-cache python3 make g++ sqlite-dev linux-headers \ | ||
| && npm rebuild better-sqlite3 --build-from-source \ | ||
| && apk del python3 make g++ sqlite-dev linux-headers \ | ||
| && rm -rf /root/.npm /root/.cache | ||
|
|
||
| # Create data directory for database persistence | ||
| RUN mkdir -p /app/data && chown subarr:subarr /app/data | ||
|
|
||
| # Switch to non-root user | ||
| USER subarr | ||
|
|
||
| # Expose port | ||
| EXPOSE 3001 | ||
|
|
||
| # Health check | ||
| HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \ | ||
| CMD wget --no-verbose --tries=1 --spider http://localhost:3001/api/playlists || exit 1 | ||
|
|
||
| # Start the server | ||
| CMD ["node", "server/index.js"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Please run `git pull` before running this compose | ||
| services: | ||
| subarr: | ||
| build: . | ||
| container_name: subarr | ||
| ports: | ||
| - "3001:3001" | ||
| volumes: | ||
| - subarr_data:/app/data | ||
| environment: | ||
| - NODE_ENV=production | ||
| - PORT=3001 | ||
| - DB_PATH=/app/data/subarr.db | ||
| restart: unless-stopped | ||
| healthcheck: | ||
| test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3001/"] | ||
| interval: 30s | ||
| timeout: 10s | ||
| retries: 3 | ||
| start_period: 40s | ||
|
|
||
| volumes: | ||
| subarr_data: | ||
| driver: local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was
npm run start-serverremoved from theupdatescript?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I attempted to make
npm run updatescript universal for docker, and a base install.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is the recommendation that "manual installs" run
npm run update:manualand docker installs runnpm run update:docker? I don't see hownpm run updatewould work for both installs (unless I don't understand something about how scripts work)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the ideal flow would go like this
Manual user:
npm run update:manualDocker user:
npm run update:dockerThis would've allowed each user update and start the application the way they would like. Typically the docker image for an app would exist in a place like dockerhub and that would allowed for docker users to not need to use node scripts. but since this is the first iteration of docker, I thought it would be okay for now.
ps. Sorry I should have included this in my pull from the beginning.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understandable. I'm quite new to docker, so I'm not very familiar. But I know it's a big request for people interested in this app.
Let's keep
update:dockeras you have it (or change it todocker:updatesince the other docker scripts have that naming convention), but let's removeupdate:manualand just go back to the regularupdatescript the way it was.