This commit is contained in:
Administrator 2022-11-07 08:25:05 +03:00
parent 7a14bf83c6
commit 323dfd59aa
5 changed files with 34 additions and 36 deletions

View File

@ -129,21 +129,17 @@ services:
parallelism: 1 parallelism: 1
order: start-first order: start-first
grafana: docker-cleaner:
image: grafana/grafana:9.1.7-ubuntu image: mathwave/sprint-repo:sprint-infra-docker-cleaner
volumes: volumes:
- /sprint-data/grafana:/var/lib/grafana - /var/run/docker.sock:/var/run/docker.sock
ports:
- "3000:3000"
deploy: deploy:
mode: replicated mode: global
placement:
constraints: [node.role == manager]
restart_policy: restart_policy:
condition: any condition: any
update_config: update_config:
parallelism: 1 parallelism: 1
order: start-first order: stop-first
volumes: volumes:
minio_data: minio_data:

View File

@ -128,38 +128,18 @@ services:
update_config: update_config:
parallelism: 1 parallelism: 1
order: start-first order: start-first
grafana:
image: grafana/grafana:9.1.7-ubuntu
volumes:
- /sprint-data/grafana:/var/lib/grafana
ports:
- "3000:3000"
deploy:
mode: replicated
placement:
constraints: [node.role == manager]
restart_policy:
condition: any
update_config:
parallelism: 1
order: start-first
registry: docker-cleaner:
image: registry:2.8.1 image: mathwave/sprint-repo:sprint-infra-docker-cleaner
volumes: volumes:
- /sprint-data/registry:/var/lib/registry - /var/run/docker.sock:/var/run/docker.sock
ports:
- "5000:5000"
deploy: deploy:
mode: replicated mode: global
placement:
constraints: [node.role == manager]
restart_policy: restart_policy:
condition: any condition: any
update_config: update_config:
parallelism: 1 parallelism: 1
order: start-first order: stop-first
volumes: volumes:
minio_data: minio_data:

View File

@ -9,9 +9,7 @@ stages:
- docker network create -d overlay --attachable swarmpit-nginx || true - docker network create -d overlay --attachable swarmpit-nginx || true
- docker network create -d overlay --attachable common-infra-nginx || true - docker network create -d overlay --attachable common-infra-nginx || true
- mkdir /sprint-data/mongo || true - mkdir /sprint-data/mongo || true
- mkdir /sprint-data/grafana || true
- mkdir /sprint-data/redis || true - mkdir /sprint-data/redis || true
- mkdir /sprint-data/registry || true
- chmod 777 /sprint-data/grafana - chmod 777 /sprint-data/grafana
- chmod 777 /sprint-data/redis - chmod 777 /sprint-data/redis
- chmod 777 /sprint-data/registry - chmod 777 /sprint-data/registry
@ -27,6 +25,8 @@ build:
- docker push mathwave/sprint-repo:sprint-infra-nginx-dev - docker push mathwave/sprint-repo:sprint-infra-nginx-dev
- docker build -t mathwave/sprint-repo:sprint-infra-nginx-prod nginx/nginx-prod - docker build -t mathwave/sprint-repo:sprint-infra-nginx-prod nginx/nginx-prod
- docker push mathwave/sprint-repo:sprint-infra-nginx-prod - docker push mathwave/sprint-repo:sprint-infra-nginx-prod
- docker build -t mathwave/sprint-repo:sprint-infra-docker-cleaner docker-cleaner
- docker push mathwave/sprint-repo:sprint-infra-docker-cleaner
deploy-dev: deploy-dev:
stage: deploy-dev stage: deploy-dev

17
docker-cleaner/Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install --yes ca-certificates curl gnupg lsb-release
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
RUN echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update --yes
RUN apt-get install --yes docker-ce docker-ce-cli containerd.io docker-compose-plugin
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
COPY clean.sh clean.sh
RUN chmod 777 clean.sh
CMD ["./clean.sh"]

5
docker-cleaner/clean.sh Normal file
View File

@ -0,0 +1,5 @@
while true
do
docker image rm $(docker image ls -q) || true
sleep(86400)
done