Skip to content

Commit

Permalink
fix: optimize docker up
Browse files Browse the repository at this point in the history
  • Loading branch information
yugasun committed Oct 18, 2023
1 parent 21b38cd commit a8f41d3
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 55 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ pnpm run build --app main
5. Start by docker:

```shell
# build image
pnpm run docker:build

# start
pnpm run docker:up
```
Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: '3.8'

services:
nginx:
image: micro-frontend-starter:latest
micro-fe:
build:
context: .
dockerfile: ./Dockerfile
container_name: micro-frontend-starter
restart: always
ports:
Expand Down
16 changes: 8 additions & 8 deletions docker/conf.d/main.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
server {
listen 8000;
server_name localhost;
listen 8000;
server_name localhost;

add_header Access-Control-Allow-Origin *;
root /opt/www/main/;
index index.html index.htm;
add_header Access-Control-Allow-Origin *;
root /opt/www/main/;
index index.html index.htm;

location / {
try_files $uri $uri/ /index.html;
}
location / {
try_files $uri $uri/ /index.html;
}
}
18 changes: 9 additions & 9 deletions docker/conf.d/subapp1.conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
server {
listen 8001;
server_name localhost;
listen 8001;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;

location / {
add_header Access-Control-Allow-Origin *;
root /opt/www/subapp1/;
index index.html index.htm;
}
location / {
add_header Access-Control-Allow-Origin *;
root /opt/www/subapp1/;
index index.html index.htm;
}
}
18 changes: 9 additions & 9 deletions docker/conf.d/subapp2.conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
server {
listen 8002;
server_name localhost;
listen 8002;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;

location / {
add_header Access-Control-Allow-Origin *;
root /opt/www/subapp2/;
index index.html index.htm;
}
location / {
add_header Access-Control-Allow-Origin *;
root /opt/www/subapp2/;
index index.html index.htm;
}
}
18 changes: 9 additions & 9 deletions docker/conf.d/subapp3.conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
server {
listen 8003;
server_name localhost;
listen 8003;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;

location / {
add_header Access-Control-Allow-Origin *;
root /opt/www/subapp3/;
index index.html index.htm;
}
location / {
add_header Access-Control-Allow-Origin *;
root /opt/www/subapp3/;
index index.html index.htm;
}
}
24 changes: 12 additions & 12 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ pid /var/run/nginx.pid;


events {
worker_connections 1024;
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;
sendfile on;
#tcp_nopush on;

keepalive_timeout 65;
keepalive_timeout 65;

#gzip on;
#gzip on;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/conf.d/*.conf;
}
2 changes: 1 addition & 1 deletion packages/subapp1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/subapp4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function build(appName: string) {
step(`[${appName}] Building`);
const runArgs = ['run', 'build'];
const cwd = join(rootDir, appName);
await runCommand('pnpm', runArgs, join(rootDir, appName));
await runCommand('pnpm', runArgs, cwd);
// copy dist to deploy dist dir
copyDist(`${cwd}/dist`, `${deployDist}/${appName}`);
} catch (e) {
Expand Down

0 comments on commit a8f41d3

Please sign in to comment.