Skip to content

Commit 9b0c1c7

Browse files
committed
Dockerfile able to start from script file
1 parent 55948a0 commit 9b0c1c7

4 files changed

Lines changed: 120 additions & 7 deletions

File tree

.github/workflows/staging.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
name: stating
3+
4+
on:
5+
push:
6+
branches:
7+
- develop
8+
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
outputs:
14+
image: ${{ steps.export.outputs.image }}
15+
tag: ${{ steps.export.outputs.tag }}
16+
17+
runs-on: ubuntu-latest
18+
env:
19+
image: cranecloud/monitoring-api
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
25+
- name: Install (Buildx)
26+
uses: docker/setup-buildx-action@v1
27+
28+
- name: Login to Docker Hub
29+
uses: docker/login-action@v2
30+
with:
31+
username: ${{ secrets.DOCKERHUB_USERNAME }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
34+
- id: meta
35+
name: Tag
36+
uses: docker/metadata-action@v3
37+
with:
38+
flavor: |
39+
latest=true
40+
images: ${{ env.image }}
41+
tags: |
42+
type=ref,event=branch
43+
type=ref,event=pr
44+
type=sha
45+
46+
- name: Build
47+
uses: docker/build-push-action@v2
48+
with:
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
51+
context: .
52+
labels: ${{ steps.meta.outputs.labels }}
53+
push: true
54+
tags: ${{ steps.meta.outputs.tags }}
55+
56+
- id: export
57+
name: Export
58+
uses: actions/github-script@v5
59+
with:
60+
script: |
61+
const metadata = JSON.parse(`${{ steps.meta.outputs.json }}`)
62+
const fullUrl = metadata.tags.find((t) => t.includes(':sha-'))
63+
if (fullUrl == null) {
64+
core.error('Unable to find sha tag of image')
65+
} else {
66+
const tag = fullUrl.split(':')[1]
67+
core.setOutput('image', fullUrl)
68+
core.setOutput('tag', tag)
69+
}
70+
71+
Microservice:
72+
name: Deploy (Microservice)
73+
74+
needs:
75+
- Build
76+
77+
runs-on: ubuntu-latest
78+
env:
79+
namespace: cranecloud-microservice
80+
image: cranecloud/monitoring-api
81+
82+
steps:
83+
- name: Checkout code
84+
uses: actions/checkout@v2
85+
86+
- uses: azure/k8s-set-context@v1
87+
with:
88+
kubeconfig: ${{ secrets.RENU_KUBECONFIG}}
89+
90+
- name: Helm Release
91+
run: |
92+
helm upgrade --install --create-namespace \
93+
monitoring-api ./helm/chart \
94+
--values helm/values.micro.yaml \
95+
--namespace $namespace \
96+
--set image.tag="${{ needs.build.outputs.tag }}" \
97+
--set environment.ADMIN_MYSQL_PASSWORD="${{ secrets.STAGING_ADMIN_MYSQL_PASSWORD }}" \
98+
--set environment.ADMIN_PSQL_PASSWORD="${{ secrets.STAGING_ADMIN_PSQL_PASSWORD }}" \
99+
--set environment.APP_MAIL_PASSWORD="${{ secrets.STAGING_APP_MAIL_PASSWORD }}" \
100+
--set environment.DATABASE_URI="${{ secrets.MICROSERVICE_DATABASE_URI }}" \
101+
--set environment.MONGO_URI="${{ secrets.STAGING_MONGO_URI }}" \
102+
--set environment.FLASK_APP_SALT="${{ secrets.STAGING_FLASK_APP_SALT }}" \
103+
--set environment.FLASK_APP_SECRET="${{ secrets.STAGING_FLASK_APP_SECRET }}" \
104+
--set environment.GITHUB_CLIENT_SECRET="${{ secrets.STAGING_GITHUB_CLIENT_SECRET }}" \
105+
--set environment.NEW_RELIC_LICENSE_KEY="${{ secrets.STAGING_NEW_RELIC_LICENSE_KEY }}" \
106+
--set environment.KUBE_SERVICE_PORT="${{ secrets.STAGING_KUBE_SERVICE_PORT }}" \
107+
--set environment.LOGGER_APP_URL="${{ secrets.MICROSERVICE_LOGGER_APP_URL }}" \
108+
--timeout=300s
109+
110+
- name: Monitor Rollout
111+
run: |
112+
kubectl rollout status deployment/cranecloud-backend --timeout=300s --namespace $namespace
113+

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ COPY . /app
2020

2121

2222
# make port available to the world outside this container
23-
EXPOSE 4000
23+
EXPOSE 5000
2424

2525
# connect to start script when db is being used
26-
CMD ["flask", "run", "--host=0.0.0.0", "--port=4000"]
26+
ENTRYPOINT ["sh", "/app/scripts/start.sh"]

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
database:
44
restart: always
55
image: postgres:10.8-alpine
6-
container_name: postgres-db
6+
container_name: monitoring-postgres-db
77
environment:
88
POSTGRES_USER: postgres
99
POSTGRES_DB: cc-monitoring
@@ -17,7 +17,7 @@ services:
1717
build:
1818
context: .
1919
dockerfile: Dockerfile
20-
container_name: flask-api
20+
container_name: monitoring-api
2121
environment:
2222
FLASK_APP_SECRET:
2323
JWT_SALT:

scripts/start.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#! /bin/bash
1+
#!/bin/bash
22

33
# source .env
44

55
# apply migrations onto db
6-
# flask db upgrade
6+
flask db upgrade
77

88
# start server
9-
flask run --host=0.0.0.0 --port=50000
9+
flask run --host=0.0.0.0 --port=5000

0 commit comments

Comments
 (0)