Skip to content

Commit db129ae

Browse files
authored
Overhaul Docker build, push and test (#375)
- Test postfacto/postfacto using postfacto/smoke on deploy - Use docker/build-push-action instead of custom scripts
1 parent 5fce8ca commit db129ae

4 files changed

Lines changed: 136 additions & 122 deletions

File tree

.github/workflows/push.yml

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,26 @@ jobs:
111111
- name: Get full tag
112112
id: full_tag
113113
run: echo ::set-output name=VERSION::${GITHUB_REF##*/}
114-
- name: Docker build
114+
- name: Get major version
115+
id: versions
115116
run: |
116-
docker build \
117-
"$GITHUB_WORKSPACE" \
118-
-f "$GITHUB_WORKSPACE/Dockerfile" \
119-
-t build-image
120-
- name: Deploy to Docker Hub
121-
if: startsWith(github.ref, 'refs/tags/')
122-
run: ./docker/ci-push $TAG
117+
echo ::set-output name=MAJOR::$(echo $VERSION | cut -d. -f1)
118+
echo ::set-output name=MINOR::$(echo $VERSION | cut -d. -f2)
123119
env:
124-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
125-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
126-
TAG: ${{ steps.full_tag.outputs.VERSION }}
120+
VERSION: ${{ steps.full_tag.outputs.VERSION }}
121+
- uses: docker/login-action@v1
122+
if: startsWith(github.ref, 'refs/tags/')
123+
with:
124+
username: ${{ secrets.DOCKERHUB_USERNAME }}
125+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
126+
- uses: docker/build-push-action@v2
127+
with:
128+
push: startsWith(github.ref, 'refs/tags/')
129+
tags: |
130+
postfacto/postfacto
131+
postfacto/postfacto:${{ steps.versions.outputs.MAJOR }}
132+
postfacto/postfacto:${{ steps.versions.outputs.MAJOR }}.${{ steps.versions.outputs.MINOR }}
133+
postfacto/postfacto:${{ steps.full_tag.outputs.VERSION }}
127134
128135
package-build:
129136
runs-on: ubuntu-20.04
@@ -200,19 +207,28 @@ jobs:
200207
- name: Get full tag
201208
id: full_tag
202209
run: echo ::set-output name=VERSION::${GITHUB_REF##*/}
203-
- name: Smoke build
210+
- name: Get major version
211+
id: versions
204212
run: |
205-
docker build \
206-
"$GITHUB_WORKSPACE/smoke" \
207-
-f "$GITHUB_WORKSPACE/docker/smoke/Dockerfile" \
208-
-t build-image-smoke
209-
- name: Deploy to Docker Hub
210-
if: startsWith(github.ref, 'refs/tags/')
211-
run: ./docker/ci-push-smoke $TAG
213+
echo ::set-output name=MAJOR::$(echo $VERSION | cut -d. -f1)
214+
echo ::set-output name=MINOR::$(echo $VERSION | cut -d. -f2)
212215
env:
213-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
214-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
215-
TAG: ${{ steps.full_tag.outputs.VERSION }}
216+
VERSION: ${{ steps.full_tag.outputs.VERSION }}
217+
- uses: docker/login-action@v1
218+
if: startsWith(github.ref, 'refs/tags/')
219+
with:
220+
username: ${{ secrets.DOCKERHUB_USERNAME }}
221+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
222+
- uses: docker/build-push-action@v2
223+
with:
224+
context: ./smoke
225+
file: ./docker/smoke/Dockerfile
226+
push: startsWith(github.ref, 'refs/tags/')
227+
tags: |
228+
postfacto/smoke
229+
postfacto/smoke:${{ steps.versions.outputs.MAJOR }}
230+
postfacto/smoke:${{ steps.versions.outputs.MAJOR }}.${{ steps.versions.outputs.MINOR }}
231+
postfacto/smoke:${{ steps.full_tag.outputs.VERSION }}
216232
217233
cf-deploy:
218234
runs-on: ubuntu-20.04
@@ -261,3 +277,27 @@ jobs:
261277
git config --global user.email "postfacto@pivotal.io"
262278
git config --global user.name "Postfacto Robot"
263279
- run: ./test-package.sh --skip-package --skip-cf
280+
281+
docker-smoke:
282+
runs-on: ubuntu-20.04
283+
if: startsWith(github.ref, 'refs/tags/')
284+
needs:
285+
- docker-build
286+
- smoke-build
287+
steps:
288+
- uses: actions/checkout@v2
289+
- uses: docker/setup-buildx-action@v1
290+
- name: Get full tag
291+
id: full_tag
292+
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
293+
- name: Smoke test Docker containers
294+
run: |
295+
docker-compose run setup
296+
docker-compose run test
297+
working-directory: docker/smoke/
298+
env:
299+
ADMIN_EMAIL: 'admin@example.com'
300+
ADMIN_PASSWORD: 'opensesame'
301+
POSTGRES_PASSWORD: 'friend'
302+
SECRET_KEY_BASE: 'supersecret'
303+
TAG: ${{ steps.full_tag.outputs.VERSION }}

docker/ci-push

Lines changed: 0 additions & 56 deletions
This file was deleted.

docker/ci-push-smoke

Lines changed: 0 additions & 44 deletions
This file was deleted.

docker/smoke/docker-compose.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#
2+
# Postfacto, a free, open-source and self-hosted retro tool aimed at helping
3+
# remote teams.
4+
#
5+
# Copyright (C) 2016 - Present Pivotal Software, Inc.
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
#
9+
# it under the terms of the GNU Affero General Public License as
10+
#
11+
# published by the Free Software Foundation, either version 3 of the
12+
#
13+
# License, or (at your option) any later version.
14+
#
15+
#
16+
#
17+
# This program is distributed in the hope that it will be useful,
18+
#
19+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
#
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
#
23+
# GNU Affero General Public License for more details.
24+
#
25+
#
26+
#
27+
# You should have received a copy of the GNU Affero General Public License
28+
#
29+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
30+
#
31+
32+
version: '3.8'
33+
34+
services:
35+
setup:
36+
image: postfacto/postfacto:${TAG}
37+
entrypoint: create-admin-user "$ADMIN_EMAIL" "$ADMIN_PASSWORD"
38+
environment:
39+
DATABASE_URL: "postgres://postgres:$POSTGRES_PASSWORD@postgres:5432"
40+
SECRET_KEY_BASE: $SECRET_KEY_BASE
41+
links:
42+
- postfacto
43+
- postgres
44+
45+
test:
46+
image: postfacto/smoke:${TAG}
47+
environment:
48+
ADMIN_EMAIL: $ADMIN_EMAIL
49+
ADMIN_PASSWORD: $ADMIN_PASSWORD
50+
BASE_ADMIN_URL: 'http://postfacto:3000/admin'
51+
BASE_WEB_URL: 'http://postfacto:3000'
52+
links:
53+
- postfacto
54+
55+
postfacto:
56+
image: postfacto/postfacto:${TAG}
57+
ports:
58+
- '3000:3000'
59+
environment:
60+
DATABASE_URL: "postgres://postgres:$POSTGRES_PASSWORD@postgres:5432"
61+
DISABLE_SSL_REDIRECT: 'true'
62+
REDIS_URL: 'redis://redis:6379'
63+
SECRET_KEY_BASE: $SECRET_KEY_BASE
64+
links:
65+
- postgres
66+
- redis
67+
68+
postgres:
69+
image: postgres
70+
environment:
71+
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
72+
73+
redis:
74+
image: redis

0 commit comments

Comments
 (0)