Skip to content

Commit 4fc8dc3

Browse files
committed
Add build-args from client to pipeline
1 parent 6013bee commit 4fc8dc3

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,19 @@ jobs:
286286
type=ref,event=pr
287287
type=sha
288288
289+
- name: Set build arguments for client
290+
id: build-args
291+
run: |
292+
if [[ "${{ matrix.service }}" == "client" ]]; then
293+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
294+
echo "build_env=production" >> $GITHUB_OUTPUT
295+
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
296+
echo "build_env=staging" >> $GITHUB_OUTPUT
297+
else
298+
echo "build_env=development" >> $GITHUB_OUTPUT
299+
fi
300+
fi
301+
289302
- name: Build and push Docker Image
290303
uses: docker/build-push-action@v5
291304
with:
@@ -295,6 +308,8 @@ jobs:
295308
push: true
296309
tags: ${{ steps.meta.outputs.tags }}
297310
labels: ${{ steps.meta.outputs.labels }}
311+
build-args: |
312+
${{ matrix.service == 'client' && format('BUILD_ENV={0}', steps.build-args.outputs.build_env) || '' }}
298313
cache-from: type=gha
299314
cache-to: type=gha,mode=max
300315

client/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,73 @@ Angular CLI does not come with an end-to-end testing framework by default. You c
5757
## Additional Resources
5858

5959
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
60+
61+
## Environment Configuration
62+
63+
The application supports multiple environments:
64+
65+
- **Development**: Uses `environment.ts` (default for local development)
66+
- **Staging**: Uses `environment.staging.ts` (for the staging environment)
67+
- **Production**: Uses `environment.prod.ts` (for the production environment)
68+
69+
## Building with Docker
70+
71+
The Dockerfile supports building the application for different environments using the `BUILD_ENV` build argument.
72+
73+
### Building for Production (default)
74+
75+
```bash
76+
docker build -t client .
77+
```
78+
79+
This will use the production environment configuration by default.
80+
81+
### Building for Staging
82+
83+
```bash
84+
docker build -t client --build-arg BUILD_ENV=staging .
85+
```
86+
87+
This will use the staging environment configuration.
88+
89+
### Building for Development
90+
91+
```bash
92+
docker build -t client --build-arg BUILD_ENV=development .
93+
```
94+
95+
This will use the development environment configuration.
96+
97+
## Environment Configuration Files
98+
99+
The environment configuration files are located in `src/environments/`:
100+
101+
- `environment.ts`: Development environment
102+
- `environment.staging.ts`: Staging environment
103+
- `environment.prod.ts`: Production environment
104+
105+
Each file contains environment-specific settings like API URLs and feature flags.
106+
107+
## CI/CD Integration
108+
109+
The project's CI/CD pipeline automatically sets the appropriate `BUILD_ENV` value based on the Git branch:
110+
111+
- **main branch**: Uses `BUILD_ENV=production` for production deployments
112+
- **dev branch**: Uses `BUILD_ENV=staging` for staging deployments
113+
- **other branches**: Uses `BUILD_ENV=development` as a fallback
114+
115+
This is implemented in the GitHub Actions workflow (`.github/workflows/ci.yml`), which automatically builds and deploys the application with the correct environment configuration.
116+
117+
### Manual CI/CD Example
118+
119+
For manual CI/CD integration, you can use the `BUILD_ENV` build argument to specify the target environment:
120+
121+
```yaml
122+
# Example for staging deployment
123+
docker build -t client --build-arg BUILD_ENV=staging .
124+
125+
# Example for production deployment
126+
docker build -t client --build-arg BUILD_ENV=production .
127+
```
128+
129+
This ensures that the correct environment configuration is used for each deployment target.

client/src/environments/environment.prod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export const environment = {
44
apiUrl: 'https://aieventconcepter.student.k8s.aet.cit.tum.de/api',
55
mockDelay: 0,
66
enableLogging: false
7-
};
7+
};

0 commit comments

Comments
 (0)