deploy frontend into s3 bucket (#33, #32)

This commit is contained in:
Art
2021-09-25 01:08:19 +03:00
parent f1001ce262
commit 906b1c9620
4 changed files with 75 additions and 2 deletions

View File

@ -174,3 +174,50 @@ WantedBy=multi-user.target
- and another
- Username: `shyshkin.art`
- Password: `5C<"0dVx=>`
#### 33 deploy frontend into s3 bucket
1. S3 console
- Create bucket: `portal.shyshkin.net`
2. Build Angular app
- create `environment.test.ts`
- modify `angular.json`
- `ng build -c test`
3. Copy files from `dist/support-portal-frontend` to the bucket
4. Static website hosting
- Enable
- index.html
5. Allow public access
- `Block public access (bucket settings)` - All OFF
6. Edit bucket policy
- `{`
- ` "Version": "2012-10-17",`
- ` "Statement": [`
- ` {`
- ` "Sid": "PublicRead",`
- ` "Effect": "Allow",`
- ` "Principal": "*",`
- ` "Action": [`
- ` "s3:GetObject",`
- ` "s3:GetObjectVersion"`
- ` ],`
- ` "Resource": "arn:aws:s3:::portal.shyshkin.net/*"`
- ` }`
- ` ]`
- `}`
7. Visit `http://portal.shyshkin.net.s3-website.eu-north-1.amazonaws.com`
8. Make an Alias to Website
- Route 53 console
- Hosted zone: shyshkin.net
- Add record
- Name: portal
- Record Type: A
- Routing policy: Simple routing
- Alias: true
- Alias to S3 website endpoint
- Stockholm
- s3-website.eu-north-1.amazonaws.com
9. Tune CORS for backend
- add `http://portal.shyshkin.net`

View File

@ -42,7 +42,7 @@ spring:
app:
public-urls: /user/login,/user/register,/user/*/image/**,/user/image/**
cors:
allowed-origins: http://localhost:4200,https://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com
allowed-origins: http://localhost:4200,https://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://portal.shyshkin.net
jwt:
secret: VeRy_5ecretP@55W0rd!
# secret: ${random.value} #Does not work - every time generates new value
@ -80,7 +80,7 @@ app:
from: d.art.shishkin@gmail.com
carbon-copy: d.art.shishkin@gmail.com
cors:
allowed-origins: http://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://support-portal.shyshkin.net
allowed-origins: http://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://support-portal.shyshkin.net,http://portal.shyshkin.net
server:
port: 5000
logging:

View File

@ -56,6 +56,27 @@
],
"outputHashing": "all"
},
"test": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,

View File

@ -0,0 +1,5 @@
export const environment = {
production: false,
apiUrl: 'http://localhost:8080',
publicUrls: ['/user/login', '/user/register', '/user/*/image/**', '/user/image/**']
};