File tree 6 files changed +82
-1
lines changed
6 files changed +82
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : Docker Compose Actions Workflow
2
+ on : push
3
+ jobs :
4
+ test :
5
+ runs-on : ubuntu-latest
6
+ steps :
7
+ - uses : actions/checkout@master
8
+ - name : Build the stack
9
+ run : docker-compose up -d
10
+ - name : Test
11
+ run : docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:5000/
Original file line number Diff line number Diff line change
1
+ FROM python:3.7-alpine
2
+ WORKDIR /code
3
+ ENV FLASK_APP app.py
4
+ ENV FLASK_RUN_HOST 0.0.0.0
5
+ RUN apk add --no-cache gcc musl-dev linux-headers
6
+ COPY requirements.txt requirements.txt
7
+ RUN pip install -r requirements.txt
8
+ COPY . .
9
+ CMD ["flask" , "run" ]
Original file line number Diff line number Diff line change 1
1
# docker-compose-actions-workflow
2
- GitHub Actions workflow example using Docker Compose to build and test a multi-container stack
2
+
3
+ This is a GitHub Actions workflow example to demonstrate building and testing a multi-container stack using ` docker-compose ` .
4
+
5
+ This sample is based on the [ Get started with Docker Compose] ( https://docs.docker.com/compose/gettingstarted/ ) documentation.
6
+
7
+ ## GitHub Actions Workflow
8
+
9
+ ** push.yml**
10
+ ``` yml
11
+ name : Docker Compose Actions Workflow
12
+ on : push
13
+ jobs :
14
+ test :
15
+ runs-on : ubuntu-latest
16
+ steps :
17
+ - uses : actions/checkout@master
18
+ - name : Build the stack
19
+ run : docker-compose up -d
20
+ - name : Test
21
+ run : docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:5000/
22
+ ` ` `
23
+
24
+ ## License
25
+
26
+ MIT License - see the [LICENSE](LICENSE) file for details
Original file line number Diff line number Diff line change
1
+ import time
2
+
3
+ import redis
4
+ from flask import Flask
5
+
6
+ app = Flask (__name__ )
7
+ cache = redis .Redis (host = 'redis' , port = 6379 )
8
+
9
+
10
+ def get_hit_count ():
11
+ retries = 5
12
+ while True :
13
+ try :
14
+ return cache .incr ('hits' )
15
+ except redis .exceptions .ConnectionError as exc :
16
+ if retries == 0 :
17
+ raise exc
18
+ retries -= 1
19
+ time .sleep (0.5 )
20
+
21
+
22
+ @app .route ('/' )
23
+ def hello ():
24
+ count = get_hit_count ()
25
+ return 'Hello World! I have been seen {} times.\n ' .format (count )
Original file line number Diff line number Diff line change
1
+ version : ' 3'
2
+ services :
3
+ web :
4
+ container_name : webapp-frontend
5
+ build : .
6
+ ports :
7
+ - " 5000:5000"
8
+ redis :
9
+ container_name : redis-backend
10
+ image : " redis:alpine"
Original file line number Diff line number Diff line change
1
+ flask
2
+ redis
You can’t perform that action at this time.
0 commit comments