-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-build.yml
52 lines (43 loc) · 1.32 KB
/
docker-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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 Node.js and install Yarn
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Yarn
run: corepack enable && corepack prepare yarn@stable --activate
# Step 3: Install dependencies and build the Next.js app
- name: Install dependencies
run: yarn install
- name: Build Next.js app
run: yarn build
# Step 4: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Step 5: Build Docker image
- name: Build Docker image
run: docker build -t webxr .
# Step 6: Test the Docker container
- name: Run Docker container
run: docker run -d -p 3000:3000 --name webxr webxr
- name: Test if container is running
run: |
sleep 5 # Wait for the container to start
curl -f http://localhost:3000 || exit 1
# Step 7: Cleanup
- name: Stop and remove Docker container
run: docker stop webxr && docker rm webxr