Skip to content

Commit b55616d

Browse files
committed
added docker files
1 parent 1fc6aed commit b55616d

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ branches:
66
- master
77
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
88
before_deploy: "npm run build-core"
9+
env:
10+
- DOCKER_IMAGE_NAME=swaggerapi/swagger-editor
911
deploy:
1012
provider: npm
1113
@@ -16,3 +18,14 @@ deploy:
1618
tags: true
1719
repo: swagger-api/swagger-editor
1820
node: '6.9'
21+
after_success:
22+
- if [ $DOCKER_HUB_USERNAME ]; then
23+
docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD;
24+
docker build -t $DOCKER_IMAGE_NAME .;
25+
if [ ! -z "$TRAVIS_TAG" ]; then
26+
docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_IMAGE_NAME:$TRAVIS_TAG;
27+
fi;
28+
if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then
29+
docker push $DOCKER_IMAGE_NAME;
30+
fi;
31+
fi;

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM alpine:3.4
2+
3+
MAINTAINER fehguy
4+
5+
RUN apk add --update nginx
6+
RUN mkdir -p /run/nginx
7+
8+
COPY nginx.conf /etc/nginx/
9+
10+
# copy swagger files to the `/js` folder
11+
COPY ./index.html /usr/share/nginx/html/
12+
ADD ./dist/*.js /usr/share/nginx/html/dist/
13+
ADD ./dist/*.css /usr/share/nginx/html/dist/
14+
ADD ./docker-run.sh /usr/share/nginx/
15+
16+
EXPOSE 8080
17+
18+
CMD ["sh", "/usr/share/nginx/docker-run.sh"]

docker-run.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /bin/sh
2+
3+
set -e
4+
5+
INDEX_FILE=/usr/share/nginx/html/index.html
6+
7+
# TODO: this is empty but we'll be adding configuration values here
8+
9+
exec nginx -g 'daemon off;'

nginx.conf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
worker_processes 1;
2+
3+
events {
4+
worker_connections 1024;
5+
}
6+
7+
http {
8+
include mime.types;
9+
default_type application/octet-stream;
10+
11+
sendfile on;
12+
13+
keepalive_timeout 65;
14+
15+
server {
16+
listen 8080;
17+
server_name localhost;
18+
19+
location / {
20+
root /usr/share/nginx/html;
21+
index index.html index.htm;
22+
if ($request_method = 'OPTIONS') {
23+
add_header 'Access-Control-Allow-Origin' '*';
24+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
25+
#
26+
# Custom headers and headers various browsers *should* be OK with but aren't
27+
#
28+
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
29+
#
30+
# Tell client that this pre-flight info is valid for 20 days
31+
#
32+
add_header 'Access-Control-Max-Age' 1728000;
33+
add_header 'Content-Type' 'text/plain charset=UTF-8';
34+
add_header 'Content-Length' 0;
35+
return 204;
36+
}
37+
if ($request_method = 'POST') {
38+
add_header 'Access-Control-Allow-Origin' '*';
39+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
40+
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
41+
}
42+
if ($request_method = 'GET') {
43+
add_header 'Access-Control-Allow-Origin' '*';
44+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
45+
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
46+
}
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)