Skip to content

Commit 3574a95

Browse files
committed
Update ci/cd, trigger pipeline
1 parent 3b089fc commit 3574a95

2 files changed

Lines changed: 36 additions & 18 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
- name: Build application
3434
run: npm run build
3535

36-
- name: Check build artifacts
37-
run: ls -la dist/
36+
- name: Print current user
37+
run: whoami
3838

3939
deploy:
4040
needs: lint-and-build
@@ -48,30 +48,45 @@ jobs:
4848

4949
- name: Build Docker image
5050
run: |
51-
docker build -t data-analyze-frontend:build-only .
51+
docker build -t data-analyze-frontend:latest .
5252
5353
- name: Extract static files
5454
run: |
55-
# Create a temporary container and copy files
56-
CONTAINER_ID=$(docker create data-analyze-frontend:build-only)
57-
docker cp $CONTAINER_ID:/dist ./frontend-dist
55+
# Create temporary directory for extraction
56+
mkdir -p ./temp-frontend
57+
58+
# Create temporary container and copy files
59+
CONTAINER_ID=$(docker create data-analyze-frontend:latest)
60+
61+
# Copy files from container
62+
docker cp $CONTAINER_ID:/app/dist ./temp-frontend/
63+
64+
# Remove temporary container
5865
docker rm $CONTAINER_ID
5966
60-
# Stopping nginx to safely update files
61-
cd /home/Skriler/deploy
62-
docker-compose stop nginx
67+
- name: Update static files
68+
run: |
69+
docker-compose -f /home/Skriler/deploy/docker-compose.yml stop nginx
6370
64-
# Copying static files
71+
# Clear old files
6572
sudo rm -rf /home/Skriler/deploy/frontend/*
66-
sudo cp -r ./frontend-dist/* /home/Skriler/deploy/frontend/
6773
68-
# Setting permissions for nginx
74+
# Copy new static files
75+
sudo cp -r ./temp-frontend/dist/* /home/Skriler/deploy/frontend/
76+
77+
# Set proper permissions for nginx
6978
sudo chown -R 101:101 /home/Skriler/deploy/frontend/
79+
sudo chmod -R 755 /home/Skriler/deploy/frontend/
7080
7181
- name: Deploy services
7282
run: |
7383
cd /home/Skriler/deploy
7484
docker-compose up -d
7585
76-
- name: Clean up unused images
77-
run: docker image prune -f
86+
- name: Clean up
87+
run: |
88+
# Remove temporary files
89+
rm -rf ./temp-frontend
90+
91+
# Remove unused images
92+
docker image prune -f

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Build-only Dockerfile
1+
# Build-only Dockerfile for Frontend
22
FROM node:22-alpine AS build
33
WORKDIR /app
44

@@ -12,6 +12,9 @@ COPY . .
1212
# Build with production optimizations
1313
RUN npm run build
1414

15-
# Final stage - just the built files
16-
FROM scratch
17-
COPY --from=build /app/dist /dist
15+
# Final stage
16+
FROM node:22-alpine AS final
17+
WORKDIR /app
18+
19+
# Copy only built files
20+
COPY --from=build /app/dist ./dist

0 commit comments

Comments
 (0)