Skip to content

Commit 22da469

Browse files
committed
chore: solve the conflict
1 parent 7c394cd commit 22da469

File tree

6 files changed

+98
-4
lines changed

6 files changed

+98
-4
lines changed

.github/workflows/cd.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- releases/*
7+
pull_request:
8+
branches:
9+
- releases/*
10+
11+
jobs:
12+
build-and-publish:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Log in to Docker Hub
20+
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
21+
22+
- name: Build, Tag, Push Docker image
23+
run: bash docker_auto_push.sh

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ services:
33
build:
44
context: ./fe_repo/
55
dockerfile: Dockerfile
6+
image: adamma1024/cvcoach_web:v2.0
67
ports:
78
- "12345:8081"
89
environment:

docker_auto_push.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# Define the path to the docker-compose.yml file
4+
COMPOSE_FILE="docker-compose.yml"
5+
6+
# Define the Docker Hub repository and tag prefix
7+
REPO="adamma1024/cvcoach_web"
8+
TAG_PREFIX="v"
9+
10+
# Function to extract the image version from the docker-compose.yml file
11+
extract_image_version() {
12+
local compose_file=$1
13+
local version=$(grep -A 5 "image:" "$compose_file" | grep -E "image: $REPO:$TAG_PREFIX[0-9]+\.[0-9]+" | awk -F':' '{print $3}')
14+
echo "$version"
15+
}
16+
17+
# Function to build, tag, and push the Docker image
18+
build_and_push() {
19+
local version=$1
20+
local image_tag="$REPO:$version"
21+
22+
echo "Building image: $REPO"
23+
docker compose build
24+
25+
echo "Tagging image: $image_tag"
26+
docker tag "$REPO" "$image_tag"
27+
28+
echo "Pushing image: $image_tag"
29+
docker push "$image_tag"
30+
}
31+
32+
# Main script execution
33+
main() {
34+
# Ensure the docker-compose.yml file exists
35+
if [[ ! -f "$COMPOSE_FILE" ]]; then
36+
echo "Error: $COMPOSE_FILE not found."
37+
exit 1
38+
fi
39+
40+
# Extract the image version for the 'web' service
41+
local version=$(extract_image_version "$COMPOSE_FILE")
42+
43+
if [[ -z "$version" ]]; then
44+
echo "Error: Unable to extract image version."
45+
exit 1
46+
fi
47+
echo "Version: " $version
48+
49+
# Build, tag, and push the Docker image
50+
build_and_push "$version"
51+
}
52+
53+
# Run the main function
54+
main

fe_repo/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ COPY package.json ./
1212

1313
# Step 5: Copy the rest of the application source code
1414
COPY . .
15+
RUN rm -rf ./node_modules
1516
RUN pnpm install
1617

1718
# Step 6: Build the Vite project for production

fe_repo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@emotion/styled": "^11.13.0",
1919
"@mui/base": "5.0.0-beta.58",
2020
"@mui/system": "^6.1.1",
21+
"@react-oauth/google": "^0.12.1",
2122
"react": "^18.3.1",
2223
"react-dom": "^18.3.1",
2324
"uuid": "^10.0.0"

fe_repo/pnpm-lock.yaml

Lines changed: 18 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)