-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from muriukialex/ft/dockerize-app
Dockerizing the web app while maintaining security best practices
- Loading branch information
Showing
9 changed files
with
152 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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,26 @@ | ||
# Include files that you wouldn't want included in your container | ||
|
||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.vs | ||
**/.vscode | ||
**/.next | ||
**/.cache | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/charts | ||
**/docker-compose* | ||
**/compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/build | ||
**/dist | ||
LICENSE | ||
README.md | ||
**/public/__env.js |
Validating CODEOWNERS rules …
This file contains 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,2 @@ | ||
# These owners will be the default owners for everything in the repo. | ||
* @muriukialex @effiecancode @Topsideboss2 |
This file contains 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,5 @@ | ||
## Contributing Guide | ||
|
||
- Fork the application, add your changes and make a [PR/MR](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) | ||
|
||
Contributions are highly welcome! |
This file contains 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,43 @@ | ||
FROM node:18-alpine as base | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json ./ | ||
|
||
FROM base as builder | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
# Install project dependencies | ||
RUN npm install | ||
RUN npm run build | ||
|
||
FROM base as production | ||
|
||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
# Install only production dependencies | ||
RUN npm ci --omit=dev | ||
|
||
RUN addgroup -g 1001 -S nodejs | ||
RUN adduser -S nextjs -u 1001 | ||
|
||
USER nextjs | ||
|
||
# Copy necessary files from builder stage | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next | ||
COPY --from=builder --chown=nextjs:nodejs /app/next.config.mjs ./ | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/package.json ./package.json | ||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/.env.local ./.env | ||
COPY --from=builder /app/entrypoint.sh ./entrypoint.sh | ||
|
||
EXPOSE 3000 | ||
|
||
# specifies the command to run when the Docker image is started | ||
ENTRYPOINT ["./entrypoint.sh"] | ||
|
This file contains 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,8 @@ | ||
start-app: | ||
docker-compose up | ||
|
||
tear-app: | ||
docker-compose down --rmi all | ||
|
||
# Phony targets to avoid conflicts with file names | ||
.PHONY: start-app tear-app |
This file contains 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 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,6 @@ | ||
version: "3" | ||
services: | ||
aws-rstart-labs: | ||
build: . | ||
ports: | ||
- "3000:3000" |
This file contains 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,7 @@ | ||
#!/bin/sh | ||
|
||
# run npm run start through pm2 | ||
pm2 start npm -- run start | ||
|
||
# show logs | ||
pm2 logs |
This file contains 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