diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..5322bf19 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.idea +doc +web diff --git a/Dockerfile b/Dockerfile index 6b8021fd..71d06059 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,13 @@ -FROM golang:onbuild -COPY config_example.json config.json +FROM golang:1.9.4 as build +WORKDIR /go/src/github.com/thrasher-/gocryptotrader +COPY . . +RUN mv -vn config_example.json config.json \ + && go get -v -d \ + && GOARCH=386 GOOS=linux CGO_ENABLED=0 go install -v \ + && mv /go/bin/linux_386 /go/bin/gocryptotrader + +FROM alpine:latest +COPY --from=build /go/bin/gocryptotrader /app/ +COPY --from=build /go/src/github.com/thrasher-/gocryptotrader/config.json /app/ +EXPOSE 9050 +CMD ["/app/gocryptotrader"] diff --git a/docker-compose.yml b/docker-compose.yml index edc093cc..0c296169 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,15 @@ -version: '2' +version: '3' + services: - web: - build: web/ - hostname: gocryptotraderweb - container_name: web - ports: - - "3333:80" - cli: - build: . - hostname: gocryptotrader - container_name: daemon - privileged: true + + web: + build: ./web + depends_on: + - cli + ports: + - "9051:80" + + cli: + build: . + ports: + - "9050:9050" diff --git a/web/.dockerignore b/web/.dockerignore new file mode 100644 index 00000000..651665bb --- /dev/null +++ b/web/.dockerignore @@ -0,0 +1,2 @@ +node_modules +.git diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 00000000..eab3b7dc --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,17 @@ +FROM node:9-alpine as build +COPY package.json package-lock.json ./ +RUN npm set progress=false \ + && npm config set depth 0 \ + && npm cache clean --force +RUN npm i \ + && mkdir /app \ + && cp -R ./node_modules /app +WORKDIR /app +COPY . . +RUN $(npm bin)/ng build --prod --build-optimizer + +FROM nginx:1.13.3-alpine +RUN rm -rf /var/www/html/* +COPY nginx/default.conf /etc/nginx/conf.d/ +COPY --from=build /app/dist /var/www/html +CMD ["nginx", "-g", "daemon off;"] diff --git a/web/nginx/default.conf b/web/nginx/default.conf new file mode 100644 index 00000000..fc9eda49 --- /dev/null +++ b/web/nginx/default.conf @@ -0,0 +1,20 @@ +server { + listen 80; + sendfile on; + default_type application/octet-stream; + gzip on; + gzip_http_version 1.1; + gzip_disable "MSIE [1-6]\."; + gzip_min_length 256; + gzip_vary on; + 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; + gzip_comp_level 9; + + root /var/www/html; + + location / { + try_files $uri $uri/ /index.html =404; + } + +}