Browse Source

Add CI support

It will build both dockerfiles, upload them to the registry, pull them
on the server and restart the systemd service that manages them.
drymer 6 months ago
parent
commit
d34d54dc3c
Signed by: drymer <drymer@autistici.org> GPG Key ID: A307D64D5DDFDAAD
3 changed files with 18 additions and 17 deletions
  1. 11
    7
      .drone.yml
  2. 4
    6
      flask.dockerfile
  3. 3
    4
      telegram.dockerfile

+ 11
- 7
.drone.yml View File

@@ -8,6 +8,7 @@ pipeline:
8 8
       - /var/run/docker.sock:/var/run/docker.sock
9 9
     when:
10 10
       event: push
11
+      branch: feature/add_ci
11 12
 
12 13
   build-server:
13 14
     image: docker
@@ -17,30 +18,31 @@ pipeline:
17 18
       - /var/run/docker.sock:/var/run/docker.sock
18 19
     when:
19 20
       event: push
21
+      branch: feature/add_ci
20 22
 
21 23
   push-server:
22 24
     image: docker
23 25
     commands:
24
-      - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD r.daemons.it
26
+      - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD r.daemons.it
25 27
       - docker push r.daemons.it/thealgorithm_server
26 28
     volumes:
27 29
       - /var/run/docker.sock:/var/run/docker.sock
28
-    secrets: [docker_user, docker_password]
30
+    secrets: [docker_username, docker_password]
29 31
     when:
30 32
       event: push
31
-      branch: master
33
+      branch: feature/add_ci
32 34
 
33 35
   push-bot:
34 36
     image: docker
35 37
     commands:
36
-      - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD r.daemons.it
38
+      - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD r.daemons.it
37 39
       - docker push r.daemons.it/thealgorithm_bot
38 40
     volumes:
39 41
       - /var/run/docker.sock:/var/run/docker.sock
40
-    secrets: [docker_user, docker_password]
42
+    secrets: [docker_username, docker_password]
41 43
     when:
42 44
       event: push
43
-      branch: master
45
+      branch: feature/add_ci
44 46
 
45 47
   ssh:
46 48
     image: appleboy/drone-ssh
@@ -55,7 +57,7 @@ pipeline:
55 57
       - sudo systemctl restart docker-algorithm_server
56 58
     when:
57 59
       event: push
58
-      branch: master
60
+      branch: feature/add_ci
59 61
 
60 62
   notify-bad:
61 63
     image: registry.daemons.it/drone-xmpp
@@ -64,6 +66,7 @@ pipeline:
64 66
     when:
65 67
       status: [failure]
66 68
       event: push
69
+      branch: feature/add_ci
67 70
 
68 71
   notify-good:
69 72
     image: registry.daemons.it/drone-xmpp
@@ -72,3 +75,4 @@ pipeline:
72 75
     when:
73 76
       status: [success]
74 77
       event: push
78
+      branch: feature/add_ci

+ 4
- 6
flask.dockerfile View File

@@ -1,10 +1,8 @@
1 1
 FROM tiangolo/uwsgi-nginx-flask:python3.7-alpine3.7
2 2
 MAINTAINER Ameba Libre "amebalibre@mailbox.org"
3
-
4
-WORKDIR /app
3
+COPY ./server/Pipfile /root/Pipfile
4
+RUN pip3.7 install pipenv && cd /root/ && pipenv lock && pipenv install \
5
+    --system --python 3.7 && rm /root/Pipfile
5 6
 COPY ./server /app
6
-
7
-RUN pip3.7 install pipenv && pipenv lock && pipenv install --system
8
-
9
-# TODO: Create ddbb at python code
7
+VOLUME /app/db/
10 8
 RUN python3.7 -c "import main; main.create_ddbb_if_not_exists()"

+ 3
- 4
telegram.dockerfile View File

@@ -1,10 +1,9 @@
1 1
 FROM python:3-alpine3.7
2 2
 MAINTAINER Ameba Libre "amebalibre@mailbox.org"
3 3
 
4
-WORKDIR /app
5
-
4
+COPY ./bot/Pipfile /root/Pipfile
5
+RUN apk add -U gcc musl-dev libffi-dev openssl-dev && pip3.7 install pipenv \
6
+    && pipenv lock && pipenv install --system && rm /root/Pipfile
6 7
 COPY ./bot /app
7 8
 
8
-RUN apk add -U gcc musl-dev libffi-dev openssl-dev && pip3.7 install pipenv && pipenv lock && pipenv install --system
9
-
10 9
 CMD [ "python", "./main.py" ]

Loading…
Cancel
Save