Skip to content

Commit 0fb04c4

Browse files
authored
Status service (#44)
1 parent bfeaaf8 commit 0fb04c4

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed

Diff for: .github/workflows/publish.yml

+38
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
11
on: [push]
22

33
jobs:
4+
deploy-status:
5+
runs-on: ubuntu-latest
6+
7+
steps:
8+
- name: Checkout code
9+
uses: actions/checkout@v3
10+
11+
- id: 'auth'
12+
uses: 'google-github-actions/auth@v1'
13+
with:
14+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
15+
16+
- name: Setup Google Cloud SDK
17+
uses: google-github-actions/setup-gcloud@v1
18+
19+
- id: get_branch
20+
run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
21+
22+
- id: set_image_name
23+
run: echo "IMAGE_NAME=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/status/${BRANCH}" >> $GITHUB_ENV
24+
25+
- name: Get the commit SHA
26+
id: get_sha
27+
run: echo "SHA=${GITHUB_SHA}" >> $GITHUB_ENV
28+
29+
- name: Build Docker Image
30+
run: docker build -t $IMAGE_NAME:$SHA -f status.Dockerfile .
31+
32+
- name: Push Docker Image to Google Artifact Registry
33+
run: |
34+
gcloud auth configure-docker us-east1-docker.pkg.dev
35+
docker push $IMAGE_NAME:$SHA
36+
37+
- name: Deploy to Cloud Run
38+
run: |
39+
gcloud run deploy status --image $IMAGE_NAME:$SHA --region us-east1
40+
if: env.BRANCH == 'main'
41+
442
deploy-api:
543
runs-on: ubuntu-latest
644

Diff for: docker-compose.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
services:
2+
status:
3+
build:
4+
context: .
5+
dockerfile: status.Dockerfile
6+
ports:
7+
- "8080:8080"
8+
29
postgres:
310
build:
411
context: .

Diff for: service/status/default.conf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
server {
2+
listen 8080;
3+
4+
# Disable access logs
5+
access_log off;
6+
7+
# Disable error logs (only log critical errors)
8+
error_log /dev/null crit;
9+
10+
location / {
11+
root /usr/share/nginx/html;
12+
index index.html index.htm;
13+
}
14+
}

Diff for: service/status/index.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"api_version": 1,
3+
"statuses": [
4+
"ok",
5+
"down for maintenance"
6+
],
7+
"status_index": 0
8+
}

Diff for: status.Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx:alpine
2+
3+
COPY service/status/default.conf /etc/nginx/conf.d/default.conf
4+
COPY service/status/index.html /usr/share/nginx/html/index.html

Diff for: test/functionality/status.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
4+
cd "$script_dir"
5+
6+
source ../util/setup.sh
7+
8+
set -xe
9+
10+
[[
11+
"$(jq '.status_index' < ../../service/status/index.html)" -lt \
12+
"$(jq '.statuses | length' < ../../service/status/index.html)"
13+
]]
14+
15+
c GET 'http://localhost:8080'

0 commit comments

Comments
 (0)