Skip to content

Commit c131e6f

Browse files
onitakerohityadavcloud
authored andcommitted
docker: add container build files and instructions (#22)
This adds: - a Dockerfile - a build script that injects some labels from git - an example nginx config for running the built webpack - instructions on how to run the container Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 7ea78b9 commit c131e6f

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed

ui/Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
FROM node:10-buster AS build
19+
20+
WORKDIR /build
21+
22+
RUN apt-get -y update && \
23+
apt-get -y upgrade
24+
25+
COPY . /build/
26+
RUN npm install
27+
RUN npm run build
28+
29+
FROM nginx:alpine AS runtime
30+
31+
LABEL org.opencontainers.image.title="CloudStack Primate" \
32+
org.opencontainers.image.description="A modern role-based progressive CloudStack UI" \
33+
org.opencontainers.image.authors="Apache CloudStack Contributors" \
34+
org.opencontainers.image.url="https://github.com/apache/cloudstack-primate" \
35+
org.opencontainers.image.documentation="https://github.com/apache/cloudstack-primate/README.md" \
36+
org.opencontainers.image.source="https://github.com/apache/cloudstack-primate" \
37+
org.opencontainers.image.vendor="The Apache Software Foundation" \
38+
org.opencontainers.image.licenses="Apache-2.0" \
39+
org.opencontainers.image.ref.name="latest"
40+
41+
COPY --from=build /build/dist/. /usr/share/nginx/html/

ui/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ server {
8888
}
8989
```
9090

91+
### Docker
92+
93+
A production-ready Docker container can also be built with the provided
94+
Dockerfile and build script.
95+
96+
Make sure Docker is installed, then run build.sh:
97+
98+
./build.sh
99+
100+
Change the example configuration in `nginx/default.conf` according to your needs.
101+
102+
Run Primate:
103+
104+
docker run -ti --rm -p 8080:80 -v $(pwd)/nginx:/etc/nginx/conf.d:ro cloudstack-primate:latest
105+
91106
## Documentation
92107

93108
### Learning Resources

ui/build.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
set -e
20+
set -x
21+
22+
GIT_TAG="$(git tag --points-at | head -n 1)"
23+
if [ -n "${GIT_REV}" ]; then
24+
LABEL_GIT_TAG="--label \"org.opencontainers.image.version=${GIT_TAG}\""
25+
fi
26+
DATE="$(date --iso-8601=seconds)"
27+
LABEL_DATE="--label \"org.opencontainers.image.created=${DATE}\""
28+
GIT_REV="$(git rev-parse HEAD)"
29+
LABEL_GIT_REV="--label \"org.opencontainers.image.revision=${GIT_REV}\""
30+
31+
docker build -t cloudstack-primate ${LABEL_DATE} ${LABEL_GIT_REV} ${LABEL_GIT_TAG} .

ui/nginx/default.conf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
server {
19+
listen 80;
20+
server_name localhost;
21+
location / {
22+
root /usr/share/nginx/html;
23+
index index.html;
24+
}
25+
location /client/ {
26+
# http://127.0.0.1:8080 should be replaced your CloudStack management
27+
# Server's actual URI
28+
proxy_pass http://127.0.0.1:8080;
29+
}
30+
}

0 commit comments

Comments
 (0)