diff --git a/.drone.yml b/.drone.yml index c27401f..08a0712 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,19 +10,34 @@ steps: - go mod tidy - go test ./... - - name: build and push - image: plugins/docker - settings: - repo: localhost:5000/link-shortener - insecure: true - tags: latest + - name: build docker image + image: docker:24 + privileged: true volumes: - - name: dockersock - path: /var/run/docker.sock + - /var/run/docker.sock:/var/run/docker.sock + commands: + - docker build -t localhost:5000/link-shortener:latest -f dockerfile . -services: - - name: redis - image: redis:latest + - name: deploy with compose + image: docker/compose:2.22.0 + privileged: true + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./:/opt/app + environment: + IMAGE: localhost:5000/link-shortener:latest + SERVER_HOST: link.dusiburg.ru + VIRTUAL_HOST: link.dusiburg.ru + VIRTUAL_PORT: 80 + LETSENCRYPT_HOST: link.dusiburg.ru + LETSENCRYPT_EMAIL: + from_secret: LETSENCRYPT_EMAIL + SERVER_PORT: 80 + REDIS_URL: redis://redis:6379 + commands: + - cd /opt/app + - docker-compose pull + - docker-compose up -d volumes: - name: dockersock diff --git a/docker-compose.yml b/docker-compose.yml index 757932c..478b9fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ services: link-shortener: - build: - context: . - dockerfile: Dockerfile + image: ${IMAGE} container_name: link-shortener-app - networks: [isolated] + networks: + - isolated + - proxy depends_on: redis: condition: service_healthy @@ -13,13 +13,13 @@ services: expose: - 8080 environment: - - SERVER_HOST=localhost - - VIRTUAL_HOST=link.dusiburg.ru - - VIRTUAL_PORT=8080 - - LETSENCRYPT_HOST=link.dusiburg.ru - - LETSENCRYPT_EMAIL=rezcjikov@mail.ru - - SERVER_PORT=8080 - - REDIS_URL=redis://redis:6379 + - SERVER_HOST=${SERVER_HOST} + - VIRTUAL_HOST=${VIRTUAL_HOST} + - VIRTUAL_PORT=${VIRTUAL_PORT} + - LETSENCRYPT_HOST=${LETSENCRYPT_HOST} + - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} + - SERVER_PORT=${SERVER_PORT} + - REDIS_URL=${REDIS_URL} healthcheck: test: ["CMD", "curl", "-fsS", "http://localhost:8080/ping"] interval: 5s @@ -50,4 +50,6 @@ volumes: networks: isolated: - driver: bridge \ No newline at end of file + driver: bridge + proxy: + external: true \ No newline at end of file