task2 deployment

main
Nikita Tokarchuk 4 years ago
parent 80fd1822c5
commit fa8509a441
  1. 40
      deploy/task2/default.conf
  2. 23
      deploy/task2/docker-compose.yml
  3. 27
      task2-backend/Dockerfile

@ -0,0 +1,40 @@
upstream backend2 {
server backend2:8081;
}
server {
listen 80;
server_name _;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location = /answer {
proxy_pass http://backend2;
}
}

@ -0,0 +1,23 @@
version: '3'
services:
static:
image: nginx
volumes:
- "./default.conf:/etc/nginx/conf.d/default.conf"
- "../../build/task2:/usr/share/nginx/html"
restart: unless-stopped
networks:
net:
ipv4_address: 10.103.204.2
backend2:
build:
dockerfile: ./task2-backend/Dockerfile
context: ../..
restart: unless-stopped
networks:
net: {}
networks:
net:
external:
name: tasks-net

@ -0,0 +1,27 @@
FROM alpine as builder
ENV GOPATH /root/go
ENV PATH ${GOPATH}/bin:${PATH}
RUN mkdir -p /app
WORKDIR /app
RUN apk add --no-cache go git curl gcc g++ make
COPY . .
RUN go build -o task2 github.com/mainnika/a-quest/task2-backend
FROM alpine
ENV GOPATH /root/go
ENV PATH ${GOPATH}/bin:${PATH}
RUN mkdir -p /app
WORKDIR /app
COPY --from=builder /app/task2 .
COPY --from=builder /app/task2-backend/config config
EXPOSE 8081
CMD ["/app/task2"]
Loading…
Cancel
Save