Skip to content

Commit

Permalink
Put Angular project into Docker containers
Browse files Browse the repository at this point in the history
  • Loading branch information
irby committed Jul 2, 2023
1 parent 1187c5f commit 9d2bd0e
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 14 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,7 @@ jobs:
- uses: actions/checkout@v2
- name: Start Docker containers
working-directory: .
run: docker-compose --project-directory . -f env/local/docker-compose.local.yml up -d
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
name: Install SPA dependencies
working-directory: ./src/spa
- run: npm start
name: Run SPA
working-directory: ./src/spa
run: docker-compose --project-directory . -f env/local/docker-compose.local.yml -f env/e2e/docker-compose.e2e.yml up -d
- run: npm install
name: Install E2E dependencies
working-directory: ./e2e
Expand Down
2 changes: 2 additions & 0 deletions env/e2e/_down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker-compose -f docker-compose.yml -f env/e2e/docker-compose.e2e.yml down
2 changes: 2 additions & 0 deletions env/e2e/_up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker-compose -f docker-compose.yml -f env/e2e/docker-compose.e2e.yml up --build
11 changes: 11 additions & 0 deletions env/e2e/docker-compose.e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3"
services:
spa:
build: ./src/spa
ports:
- "4200:80"
networks:
- secrets-net

networks:
secrets-net:
6 changes: 4 additions & 2 deletions src/api/SecretsSharingTool.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
options.AddPolicy(name: MyAllowSpecificOrigins,
policy =>
{
policy.AllowAnyOrigin();
policy.AllowAnyHeader();
policy
.WithOrigins("http://localhost:4200", "http://spa")
.AllowAnyHeader()
.AllowAnyMethod();
});
});

Expand Down
9 changes: 9 additions & 0 deletions src/spa/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:latest as node
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build --prod

FROM nginx:alpine
COPY --from=node /app/dist/spa /usr/share/nginx/html
EXPOSE 80
2 changes: 1 addition & 1 deletion src/spa/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
"maximumError": "10kb"
}
],
"fileReplacements": [
Expand Down
4 changes: 3 additions & 1 deletion src/spa/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const environment = {
production: true
production: true,
appUrl: "http://localhost:4200",
apiUrl: "http://localhost:5000"
};

0 comments on commit 9d2bd0e

Please sign in to comment.