-
-
Notifications
You must be signed in to change notification settings - Fork 56
Setting up ezshare with Docker Compose #129
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
dayal18
wants to merge
6
commits into
mifi:master
Choose a base branch
from
dayal18:feature/docker-compose
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.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7352d9d
Setting up ezshare with Docker Compose
dayal18 46449e6
Simple Dockerfile using Node as base image
dayal18 f126e7a
Update Dockerfile
dayal18 1bf550a
security fixes, docker-compose and README instructions
dayal18 63ef85b
Update README.md
dayal18 624b502
Update README.md
dayal18 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,74 @@ | ||
| # ========================================== | ||
| # STAGE 1: The Builder (Heavy, used only for compiling) | ||
| # ========================================== | ||
| FROM node:20 AS builder | ||
|
|
||
| RUN corepack enable | ||
| WORKDIR /app | ||
|
|
||
| # Install git | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends git && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Git Clone branch and repository | ||
| RUN git clone https://github.com/mifi/ezshare.git . | ||
|
|
||
| # Copy the source code (enable this if using for development mode - you'll need to have local copy of the code) | ||
| #COPY ezshare/ ./ | ||
|
|
||
| # Install ALL dependencies (including dev tools like TypeScript) and build | ||
| RUN yarn install --immutable | ||
| RUN yarn build | ||
|
|
||
| # ========================================== | ||
| # STAGE 2: The Runner (Lightweight, final production image) | ||
| # ========================================== | ||
| # We use node:20-slim here, which is hundreds of MBs smaller! | ||
| FROM node:20-slim AS runner | ||
|
|
||
| # Install ffmpeg, xsel, xvfb and immediately clean up the apt cache to save space | ||
| RUN apt-get update && \ | ||
| apt-get install --no-install-recommends -y xvfb ffmpeg xsel dbus && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN corepack enable | ||
| WORKDIR /app | ||
|
|
||
dayal18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Copy ONLY the necessary files from the "builder" stage | ||
| COPY --from=builder /app/package.json ./ | ||
| COPY --from=builder /app/yarn.lock ./ | ||
| COPY --from=builder /app/.yarnrc.yml ./ | ||
| COPY --from=builder /app/.yarn ./.yarn | ||
|
|
||
| # Copy the packages folder (which now contains the built "dist" folders) | ||
| COPY --from=builder /app/packages ./packages | ||
|
|
||
| # Optional but recommended: Remove the heavy "src" folders since we only need "dist" now | ||
| RUN rm -rf packages/*/src | ||
|
|
||
| # Install ONLY production dependencies (ignores devDependencies) and clean Yarn cache | ||
| RUN yarn workspaces focus --production $(node -p "require('./packages/cli/package.json').name") && yarn cache clean --all | ||
|
|
||
| #To have fake display | ||
| RUN echo '#!/bin/bash\n\ | ||
| Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &\n\ | ||
| export DISPLAY=:99\n\ | ||
| sleep 1\n\ | ||
| exec dbus-run-session -- "$@"' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh | ||
|
|
||
| # Create the shared directory | ||
| RUN mkdir /shared | ||
|
|
||
| # --- SECURITY CHANGES START --- | ||
| # 1. Change ownership of /app and /shared to the 'node' user (UID 1000) | ||
| # This ensures the user can write to these locations. | ||
| RUN chown -R node:node /app /shared | ||
|
|
||
| # 2. Switch to non-root user | ||
| USER node | ||
| # --- SECURITY CHANGES END --- | ||
|
|
||
| # Expose port and start | ||
| EXPOSE 3003 | ||
| CMD ["/app/entrypoint.sh", "node", "packages/cli/dist/index.js", "/shared", "--port", "3003"] | ||
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,19 @@ | ||
| services: | ||
| ezshare: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| container_name: ezshare-app | ||
| restart: unless-stopped | ||
|
|
||
| # Map port 3003 on host to 3003 in container | ||
| ports: | ||
| - "3003:3003" | ||
|
|
||
| # Mount a local directory to /shared | ||
| volumes: | ||
| - ./my-shared/path:/shared | ||
|
|
||
| # (Optional) Ensure the container uses the node user explicitly | ||
| # though the Dockerfile USER instruction already handles this. | ||
| user: "node" |
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.
Uh oh!
There was an error while loading. Please reload this page.