-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: 🔧 Add Docker configuration files and Dockerfile for building and …
…running the app
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 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,7 @@ | ||
Dockerfile | ||
.dockerignore | ||
node_modules | ||
npm-debug.log | ||
README.md | ||
.next | ||
.git |
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,25 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GH_Token }} | ||
|
||
- name: Build the Docker image | ||
run: docker build . --file Dockerfile --tag ghcr.io/${{ github.repository }}:latest | ||
|
||
- name: Push the Docker image | ||
run: docker push ghcr.io/${{ github.repository }}:latest |
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,42 @@ | ||
# Stage 1: Building the app | ||
FROM node:18-alpine AS builder | ||
|
||
# Set the working directory in the Docker container | ||
WORKDIR /app | ||
|
||
# Copy the package.json and package-lock.json (or yarn.lock) files | ||
COPY package*.json ./ | ||
# If you're using Yarn, uncomment the next line and remove the COPY command above | ||
# COPY package.json yarn.lock ./ | ||
|
||
# Install dependencies | ||
RUN npm ci | ||
# For Yarn, use the following command instead | ||
# RUN yarn install | ||
|
||
# Copy the rest of your app's source code from your host to your image filesystem. | ||
COPY . . | ||
|
||
# Build the Next.js application | ||
RUN npm run build | ||
# For Yarn, use the following command instead | ||
# RUN yarn build | ||
|
||
# Stage 2: Run the app | ||
FROM node:18-alpine AS runner | ||
WORKDIR /app | ||
|
||
# Copy the build output from the builder stage | ||
COPY --from=builder /app/next.config.mjs ./ | ||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/.next ./.next | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/package.json ./package.json | ||
|
||
# Expose the port Next.js runs on | ||
EXPOSE 3000 | ||
|
||
# Command to run the app | ||
CMD ["npm", "start"] | ||
# For Yarn, use the following command instead | ||
# CMD ["yarn", "start"] |