-
Notifications
You must be signed in to change notification settings - Fork 96
Simple implementation of Docker for development and production #96
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
ppastene
wants to merge
13
commits into
max-programming:main
Choose a base branch
from
ppastene:feature/docker
base: main
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.
+140
−0
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0ccc3a2
Simplem implementation of Docker for development and production
30b7ea3
Simplem implementation of Docker for development and production
de68a6b
Update on docker-compose.dev
ppastene f10ee66
Merge branch 'feature/docker' of https://github.com/ppastene/hacktobe…
ppastene fc53282
Adding Docker usage with the project
ppastene 8b71ec5
Removing restart property for dev compose
ppastene aa65456
Adding restart property for prod compose
ppastene b9f03af
Remove of detatched option
ppastene cc8e515
Add files to skip in Docker
ppastene b030e68
Add the watch option for the development setup
ppastene d6da84a
Update on the development deployment
ppastene c0a9337
Update on the production deployment
ppastene 02652e9
Merge branch 'main' into feature/docker
max-programming 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,15 @@ | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
/docker | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.vercel | ||
.gitignore | ||
.github | ||
.next | ||
.prettierrc |
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,23 @@ | ||
build-dev: | ||
docker-compose -f docker/docker-compose.dev.yml build --no-cache | ||
|
||
run-dev: | ||
docker-compose -f docker/docker-compose.dev.yml up | ||
|
||
stop-dev: | ||
docker-compose -f docker/docker-compose.dev.yml down | ||
|
||
rm-dev: | ||
docker-compose -f docker/docker-compose.dev.yml down -v | ||
|
||
build-prod: | ||
docker-compose -f docker/docker-compose.prod.yml build --no-cache | ||
|
||
run-prod: | ||
docker-compose -f docker/docker-compose.prod.yml up | ||
|
||
stop-prod: | ||
docker-compose -f docker/docker-compose.prod.yml down | ||
|
||
rm-prod: | ||
docker-compose -f docker/docker-compose.prod.yml down -v |
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,21 @@ | ||
FROM node:18-slim AS base | ||
|
||
RUN npm i -g pnpm | ||
|
||
FROM base AS dependencies | ||
|
||
COPY package*.json pnpm-lock.yaml ./ | ||
|
||
RUN pnpm install | ||
|
||
FROM base AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
COPY --from=dependencies /node_modules ./node_modules | ||
|
||
FROM builder AS dev | ||
|
||
CMD ["pnpm", "dev"] |
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,40 @@ | ||
FROM node:18-alpine AS base | ||
|
||
RUN npm i -g pnpm | ||
|
||
FROM base AS dependencies | ||
|
||
COPY package*.json pnpm-lock.yaml ./ | ||
|
||
RUN pnpm install | ||
|
||
FROM base AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
COPY --from=dependencies /node_modules ./node_modules | ||
|
||
RUN pnpm build | ||
|
||
FROM builder AS prod | ||
|
||
ENV NODE_ENV production | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
RUN mkdir .next | ||
RUN chown nextjs:nodejs .next | ||
|
||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["pnpm", "start"] |
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,17 @@ | ||
version: '3.8' | ||
|
||
services: | ||
app: | ||
container_name: hacktoberfest_projects_dev | ||
build: | ||
context: ../ | ||
dockerfile: docker/Dockerfile.dev | ||
target: dev | ||
environment: | ||
- NODE_ENV=development | ||
ports: | ||
- 3000:3000 | ||
volumes: | ||
- ../:/app | ||
- /app/node_modules | ||
- /app/.next |
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,12 @@ | ||
version: '3.8' | ||
|
||
services: | ||
app: | ||
container_name: hacktoberfest_projects_prod | ||
build: | ||
context: ../ | ||
dockerfile: docker/Dockerfile.prod | ||
target: prod | ||
restart: on-failure | ||
ports: | ||
- 3000:3000 |
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
Oops, something went wrong.
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.
Try adding
restart: on-failure
for cases when it failsThere 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've added the restart property for production, before I've added it for development too but now I've removed it