mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-21 17:55:30 +01:00
Add docker build to deploy Harbor UI for testing (#15381)
Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
9e11753949
commit
9a10c6627b
1
.gitignore
vendored
1
.gitignore
vendored
@ -37,6 +37,7 @@ src/portal/src/**/*.js
|
||||
src/portal/src/**/*.js.map
|
||||
src/portal/src/lib/coverage
|
||||
src/portal/ng-swagger-gen
|
||||
src/portal/docker-build/nginx.conf
|
||||
**/npm*.log
|
||||
|
||||
**/*ngsummary.json
|
||||
|
35
src/portal/docker-build/Dockerfile
Normal file
35
src/portal/docker-build/Dockerfile
Normal 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;"]
|
23
src/portal/docker-build/README.md
Normal file
23
src/portal/docker-build/README.md
Normal 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
|
41
src/portal/docker-build/nginx.conf.example
Normal file
41
src/portal/docker-build/nginx.conf.example
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user