Add docker build to deploy Harbor UI for testing (#15381)

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
孙世军 2021-08-09 10:37:49 +08:00 committed by GitHub
parent 9e11753949
commit 9a10c6627b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 100 additions and 0 deletions

1
.gitignore vendored
View File

@ -37,6 +37,7 @@ src/portal/src/**/*.js
src/portal/src/**/*.js.map src/portal/src/**/*.js.map
src/portal/src/lib/coverage src/portal/src/lib/coverage
src/portal/ng-swagger-gen src/portal/ng-swagger-gen
src/portal/docker-build/nginx.conf
**/npm*.log **/npm*.log
**/*ngsummary.json **/*ngsummary.json

View File

@ -0,0 +1,35 @@
FROM node:16.5.0 as builder
WORKDIR /build_dir
COPY src/portal /build_dir
COPY api/v2.0/legacy_swagger.yaml /build_dir/swagger.yaml
COPY api/v2.0/swagger.yaml /build_dir/swagger2.yaml
COPY api/swagger.yaml /build_dir/swagger3.yaml
RUN apt-get update \
&& apt-get install -y --no-install-recommends python-yaml
RUN npm install --unsafe-perm
RUN npm run postinstall
RUN npm run generate-build-timestamp
RUN node --max_old_space_size=2048 'node_modules/@angular/cli/bin/ng' build --configuration production
RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger.yaml > dist/swagger.json
RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger2.yaml > dist/swagger2.json
RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger3.yaml > dist/swagger3.json
COPY LICENSE /build_dir/dist
FROM nginx:1.17
COPY --from=builder /build_dir/dist /usr/share/nginx/html
COPY src/portal/docker-build/nginx.conf /etc/nginx/nginx.conf
EXPOSE 8080
VOLUME /var/cache/nginx /var/log/nginx /run
STOPSIGNAL SIGQUIT
HEALTHCHECK CMD curl --fail -s http://127.0.0.1:8080 || exit 1
USER nginx
CMD ["nginx", "-g", "daemon off;"]

View File

@ -0,0 +1,23 @@
Steps to deploy Harbor UI in a nginx container, it can be used for testing
1. Go to docker-build dir
`cd ./docker-build`
2. Copy `nginx.conf.example` to `nginx.conf`, and modify nginx.conf file to specify an available back-end server
`cp nginx.conf.example nginx.conf`
`location ~ /(api|c)/* {
proxy_pass ${an available back-end server addr};
}`
3. Build harbor-ui image
`docker build -f ./Dockerfile -t harbor-ui:test ./../../..`
4. Run harbor-ui image
`docker run -p 8080:8080 harbor-ui:test`
5. Open your browser on http://localhost:8080

View File

@ -0,0 +1,41 @@
worker_processes auto;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
client_body_temp_path /tmp/client_body_temp;
proxy_temp_path /tmp/proxy_temp;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;
server {
listen 8080;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
location / {
try_files $uri $uri/ /index.html;
}
location = /index.html {
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
location ~ /(api|c)/* {
proxy_pass https://example.com;
}
}
}