-
Notifications
You must be signed in to change notification settings - Fork 0
chore: create dockerfile #6
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f36fb60
chore: create dockerfile
peppescg 1f639b4
leftover
peppescg 45c126b
chore: use pinned pnpm version
peppescg 4e5032a
chore: node version 22
peppescg 5b7e14e
chore: add makefile
peppescg 4d57396
leftover
peppescg 19a7217
chore: add docker image tag to makefile
peppescg 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,16 @@ | ||
| Dockerfile | ||
| .dockerignore | ||
| node_modules | ||
| npm-debug.log | ||
| README.md | ||
| .next | ||
| .git | ||
| .gitignore | ||
| .vscode | ||
| .idea | ||
| *.md | ||
| .DS_Store | ||
| .env*.local | ||
| coverage | ||
| .vercel | ||
|
|
||
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,65 @@ | ||
| FROM node:22-alpine AS base | ||
|
|
||
| # Install dependencies only when needed | ||
peppescg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| FROM base AS deps | ||
| # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
| RUN apk add --no-cache libc6-compat | ||
|
|
||
| # Install pnpm | ||
| RUN corepack enable && corepack prepare pnpm@10.18.3 --activate | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install dependencies based on the preferred package manager | ||
peppescg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| COPY package.json pnpm-lock.yaml* ./ | ||
| RUN pnpm install --frozen-lockfile | ||
|
|
||
| # Rebuild the source code only when needed | ||
| FROM base AS builder | ||
|
|
||
| # Install pnpm | ||
| RUN corepack enable && corepack prepare pnpm@10.18.3 --activate | ||
|
|
||
| WORKDIR /app | ||
| COPY --from=deps /app/node_modules ./node_modules | ||
| COPY . . | ||
|
|
||
| # Next.js collects completely anonymous telemetry data about general usage. | ||
| # Learn more here: https://nextjs.org/telemetry | ||
| # Uncomment the following line in case you want to disable telemetry during the build. | ||
| # ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
|
||
| RUN pnpm build | ||
|
|
||
| # Production image, copy all the files and run next | ||
| FROM base AS runner | ||
| WORKDIR /app | ||
|
|
||
| ENV NODE_ENV=production | ||
| # Uncomment the following line in case you want to disable telemetry during runtime. | ||
| # ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
|
||
| RUN addgroup --system --gid 1001 nodejs | ||
| RUN adduser --system --uid 1001 nextjs | ||
|
|
||
| COPY --from=builder /app/public ./public | ||
|
|
||
| # Set the correct permission for prerender cache | ||
| RUN mkdir .next | ||
| RUN chown nextjs:nodejs .next | ||
|
|
||
| # Automatically leverage output traces to reduce image size | ||
| # https://nextjs.org/docs/advanced-features/output-file-tracing | ||
| COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
| COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
|
||
| USER nextjs | ||
|
|
||
| EXPOSE 3000 | ||
|
|
||
| ENV PORT=3000 | ||
|
|
||
| # server.js is created by next build from the standalone output | ||
| # https://nextjs.org/docs/pages/api-reference/config/next-config-js/output | ||
| ENV HOSTNAME="0.0.0.0" | ||
| CMD ["node", "server.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| .PHONY: help build start stop restart logs clean dev shell rebuild | ||
|
|
||
| # Variables | ||
| IMAGE_NAME := toolhive-cloud-ui | ||
| IMAGE_TAG := latest | ||
| CONTAINER_NAME := toolhive-cloud-ui | ||
| PORT := 3000 | ||
|
|
||
| ## Show this help message | ||
| help: | ||
| @echo "Available commands:" | ||
| @grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## //' | awk 'NR%2==1{printf "\033[36m%-15s\033[0m ",$$1} NR%2==0{print}' | ||
|
|
||
| ## Build the production docker image | ||
| build: | ||
| @echo "Building ${IMAGE_NAME}:${IMAGE_TAG} Docker image..." | ||
| @docker build -t $(IMAGE_NAME):$(IMAGE_TAG) . | ||
|
|
||
| ## Start the production docker container | ||
| start: | ||
| @docker run -d -p $(PORT):$(PORT) --name $(CONTAINER_NAME) $(IMAGE_NAME):$(IMAGE_TAG) | ||
| @echo "Container $(CONTAINER_NAME) running at http://localhost:$(PORT)" | ||
|
|
||
| ## Stop the production docker container | ||
| stop: | ||
| @docker stop $(CONTAINER_NAME) > /dev/null 2>&1 || true | ||
| @docker rm $(CONTAINER_NAME) > /dev/null 2>&1 || true | ||
| @echo "Container $(CONTAINER_NAME) stopped" | ||
|
|
||
| ## Restart the production docker container | ||
| restart: stop start | ||
|
|
||
| ## Show container logs (follow mode) | ||
| logs: | ||
| docker logs -f $(CONTAINER_NAME) | ||
|
|
||
| ## Remove container and image | ||
| clean: stop | ||
| @docker rmi $(IMAGE_NAME):$(IMAGE_TAG) > /dev/null 2>&1 || true | ||
| @echo "Cleanup complete" | ||
|
|
||
| ## Run development server locally | ||
| dev: | ||
| pnpm dev | ||
peppescg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Open shell in running container | ||
| shell: | ||
| docker exec -it $(CONTAINER_NAME) /bin/sh | ||
|
|
||
| ## Clean and rebuild image | ||
| rebuild: clean build | ||
| @echo "Rebuild complete" | ||
|
|
||
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
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.