-
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.
- Loading branch information
1 parent
772906d
commit 6aeb722
Showing
1 changed file
with
44 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,44 @@ | ||
name: Docker Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Checkout the code from the repository | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
# Step 2: Set up Docker Buildx for multi-platform builds (optional) | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
# Step 3: Log in to Docker Hub (Optional, if you need to push the image to Docker Hub) | ||
# Uncomment and replace DOCKER_USERNAME and DOCKER_PASSWORD in Secrets if needed | ||
# - name: Log in to Docker Hub | ||
# uses: docker/login-action@v2 | ||
# with: | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
# Step 4: Build the Docker image | ||
- name: Build Docker image | ||
run: docker build -t my-nextjs-app . | ||
|
||
# Step 5: (Optional) Run Docker container for testing | ||
- name: Run Docker container | ||
run: docker run -d -p 3000:3000 --name my-nextjs-app my-nextjs-app | ||
|
||
# Step 6: Verify the container is running (Optional) | ||
- name: Test if container is running | ||
run: | | ||
sleep 5 # Wait for the container to start | ||
curl -f http://localhost:3000 || exit 1 |