-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
60 lines (56 loc) · 1.59 KB
/
.gitlab-ci.yml
File metadata and controls
60 lines (56 loc) · 1.59 KB
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
53
54
55
56
57
58
59
60
stages:
- deploy-backend
- build-frontend
- deploy-frontend
variables:
AWS_REGION: "ap-southeast-5"
AWS_DEFAULT_REGION: "ap-southeast-5"
LAMBDA_FUNCTION_NAME: "studywat-backend"
S3_BUCKET_NAME: "studywat-frontend-my"
deploy_backend:
stage: deploy-backend
image: python:3.12
rules:
- changes:
- backend/**/*
- .gitlab-ci.yml
before_script:
- pip install --upgrade pip
- pip install awscli
script:
- cd backend
- mkdir -p lambda_build/src
- "pip install --platform manylinux2014_x86_64 --target=lambda_build --implementation cp --python-version 3.12 --only-binary=:all: --upgrade -r requirements.txt"
- cp -r src/* lambda_build/src/
- apt-get update && apt-get install -y zip
- cd lambda_build && zip -r ../fastapi_lambda.zip . && cd ..
- aws lambda update-function-code --function-name $LAMBDA_FUNCTION_NAME --zip-file fileb://fastapi_lambda.zip --region $AWS_REGION
build_frontend:
stage: build-frontend
image: node:20
rules:
- changes:
- frontend/**/*
- .gitlab-ci.yml
script:
- cd frontend
- npm ci
- echo "VITE_API_URL=$VITE_API_URL" > .env
- npm run build
artifacts:
paths:
- frontend/dist/
deploy_frontend:
stage: deploy-frontend
image: python:3.12
dependencies:
- build_frontend
rules:
- changes:
- frontend/**/*
- .gitlab-ci.yml
before_script:
- pip install awscli
script:
- aws s3 sync frontend/dist/ s3://$S3_BUCKET_NAME/ --delete
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths '/*'