Skip to content

Commit 4e62cbe

Browse files
committed
Merge remote-tracking branch 'origin/feature/hide-share-button-from-my-project-page' into feature/hide-share-button-from-my-project-page
2 parents d0c4c07 + 8bfaf45 commit 4e62cbe

16 files changed

Lines changed: 168 additions & 148 deletions

File tree

.github/workflows/build-and-deploy-images.yml

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

.github/workflows/deployment-staging.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Integrate changes and deploy
2+
3+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
4+
on:
5+
workflow_call:
6+
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs
7+
inputs:
8+
image-tag:
9+
type: string
10+
required: true
11+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callsecrets
12+
secrets:
13+
kube-context:
14+
required: true
15+
image-repo-username:
16+
required: true
17+
image-repo-password:
18+
required: true
19+
20+
jobs:
21+
integrate:
22+
runs-on: ubuntu-latest
23+
24+
env:
25+
# https://docs.docker.com/develop/develop-images/build_enhancements/
26+
DOCKER_BUILDKIT: 1
27+
28+
defaults:
29+
run:
30+
working-directory: docker
31+
32+
steps:
33+
-
34+
uses: actions/checkout@v2
35+
-
36+
run: |
37+
docker --version
38+
docker-compose --version
39+
-
40+
name: Establish image name
41+
id: image
42+
run: |
43+
echo ::set-output name=NAMESPACE::sillsdev/web-languageforge
44+
echo ::set-output name=TAG::${{ inputs.image-tag }}
45+
-
46+
name: Build app
47+
run: docker-compose build --build-arg ENVIRONMENT=production --build-arg BUILD_VERSION=${{ steps.image.outputs.TAG }} app
48+
-
49+
run: docker-compose run --rm app cat /var/www/html/build-version.txt /var/www/html/version.php
50+
-
51+
name: Check unit tests
52+
run: make unit-tests-ci
53+
-
54+
name: Check e2e tests
55+
run: make e2e-tests-ci
56+
-
57+
name: Log in to Docker Hub
58+
uses: docker/login-action@v1
59+
with:
60+
username: ${{ secrets.image-repo-username }}
61+
password: ${{ secrets.image-repo-password }}
62+
-
63+
name: Tag image
64+
run: docker tag lf-app ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG }}
65+
-
66+
name: Publish image
67+
run: docker push ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG }}
68+
69+
outputs:
70+
IMAGE: ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG }}
71+
72+
deploy:
73+
runs-on: [self-hosted, languageforge]
74+
75+
needs: integrate
76+
77+
steps:
78+
-
79+
uses: sillsdev/common-github-actions/install-kubectl@v1
80+
-
81+
run: kubectl --context ${{ secrets.kube-context }} set image deployment/app app=${{ needs.integrate.outputs.IMAGE }}

.github/workflows/production.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy to production
2+
3+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
4+
on:
5+
push:
6+
tags:
7+
- v*
8+
9+
jobs:
10+
production:
11+
if: github.event.base_ref == 'refs/heads/master'
12+
13+
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_iduses
14+
uses: sillsdev/web-languageforge/.github/workflows/integrate-and-deploy.yml@master
15+
with:
16+
image-tag: $(echo ${{ github.ref }} | sed 's/refs\/tags\///')
17+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idsecrets
18+
secrets:
19+
kube-context: ${{ secrets.LTOPS_K8S_PRODUCTION_CONTEXT }}
20+
image-repo-username: ${{ secrets.DOCKERHUB_USERNAME }}
21+
image-repo-password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

.github/workflows/staging.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Deploy to staging
2+
3+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
4+
on:
5+
push:
6+
branches:
7+
- develop
8+
9+
jobs:
10+
staging:
11+
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_iduses
12+
uses: sillsdev/web-languageforge/.github/workflows/integrate-and-deploy.yml@develop
13+
with:
14+
image-tag: develop-$(date +%Y%m%d)-${{ github.sha }}
15+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idsecrets
16+
secrets:
17+
kube-context: ${{ secrets.LTOPS_K8S_STAGING_CONTEXT }}
18+
image-repo-username: ${{ secrets.DOCKERHUB_USERNAME }}
19+
image-repo-password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

.github/workflows/tests.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ jobs:
1717
runs-on: ubuntu-latest
1818

1919
steps:
20-
- uses: actions/checkout@v2
21-
- uses: satackey/action-docker-layer-caching@v0.0.11
22-
23-
- name: Run Unit Tests
20+
-
21+
uses: actions/checkout@v2
22+
-
23+
name: Run Unit Tests
2424
run: make unit-tests-ci
25-
26-
- name: echo working directory contents
27-
run: ls -l
28-
29-
- name: Publish Test Results
25+
-
26+
name: Publish Test Results
3027
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
3128
if: always()
3229
with:
@@ -38,13 +35,16 @@ jobs:
3835
runs-on: ubuntu-latest
3936

4037
steps:
41-
- uses: actions/checkout@v2
42-
- uses: satackey/action-docker-layer-caching@v0.0.11
43-
44-
- name: Run E2E Tests
38+
-
39+
uses: actions/checkout@v2
40+
-
41+
name: Build app
42+
run: make build
43+
-
44+
name: Run E2E Tests
4545
run: make e2e-tests-ci
46-
47-
- name: Publish Test Results
46+
-
47+
name: Publish Test Results
4848
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
4949
if: always()
5050
with:

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,6 @@ After a minute or two, your source or test changes should be applied and you sho
166166

167167
1. `make dev` will start the app in development mode, i.e. changes to source code will immediately be reflected in the locally running app.
168168

169-
### Building for deployment
170-
171-
1. Refer to `/.github/workflows/build-and-deploy-images.yml` for production build commands and `/.github/workflows/deployment-staging.yml` for staging build commands.
172-
173169
### Visual Studio Code ###
174170

175171
Visual Studio Code is a simple, free, cross-platform code editor. You can download VS Code from [here](https://code.visualstudio.com/).
@@ -237,24 +233,26 @@ To debug the tests:
237233
- To debug in VSCode, select the "Node debugger" debug configuration and run it.
238234

239235
## Application deployment ##
240-
Language Forge is built to run in a containerized environment. For now, Kubernetes is the chosen runtime platform. Deployments are not currently automated and must be manually run with the appropriate credentials or from within our CD platform, TeamCity at this time. Deployment scripts for k8s can be found in `docker/deployment`
236+
Language Forge is built to run in a containerized environment. For now, Kubernetes is the chosen runtime platform. Deployments are automated under the right circumstances using GitHub Actions.
241237

242238
### Staging (QA) ###
243-
Staging deployments can be run with `VERSION=<some-docker-tag-or-semver> make deploy-staging`.
239+
Staging deployments can be manually run with `VERSION=<some-docker-tag-or-semver> make deploy-staging`.
244240

245241
Current workflow:
246-
1. merge commits into or make commits on `develop` branch
247-
1. this will kick off the GHA (`.github/workflows/deployment-staging.yml`) to build, publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags) and deploy to the staging environment.
242+
1. merge PR into or make commits on `develop` branch
243+
1. this will kick off the GHA (`.github/workflows/staging.yml`) to build, test and publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags) and deploy this code to the staging environment at https://qa.languageforge.org
248244

249245
### Production ###
250-
Production deployments can be run with `VERSION=<some-docker-tag-or-semver> make deploy-prod`.
246+
Production deployments can be manually run with `VERSION=<some-docker-tag-or-semver> make deploy-prod`.
251247

252248
Current workflow:
253249
1. merge from `develop` into `master`
254250
1. "Draft a new release" on https://github.com/sillsdev/web-languageforge/releases with a `v#.#.#` tag format
255251
1. "Publish" the new release
256-
1. this will kick off the GHA (`.github/workflows/build-and-deploy-images.yml`) to build and publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags)
257-
1. then the deployment scripts can be run either manually or via the TeamCity deploy job
252+
1. this will kick off the GHA (`.github/workflows/production.yml`) to build, test and publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags) and deploy this code to the production environment at https://languageforge.org
253+
254+
### Revert ###
255+
Various tagged images are maintained in Docker Hub. If you need to revert to a previous version, you can do so by running the deployments scripts with the appropriate permissions or utilizing the Kubernetes UI to change the image of a deployment at any time.
258256

259257
### Backup/Restore ###
260258
Backups will be established automatically by LTOps and utilized by LF through the `storageClassName` property in a Persistent Volume Claim. This storage class provided by LTOps establishes both a frequency and retention for a backup. Any time a restoration is needed, the LF team will need to coordinate the effort with LTOps. The process of restoring from a point in time will require the application be brought down for maintenance. The process will roughly follow these steps:

docker/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ dev: start
1010
docker-compose up -d ui-builder
1111

1212
.PHONY: e2e-tests
13-
e2e-tests: build
13+
e2e-tests:
1414
docker-compose build app-for-e2e test-e2e
1515
docker-compose restart app-for-e2e || docker-compose up -d app-for-e2e
1616
docker-compose run -e TEST_SPECS=$(TEST_SPECS) test-e2e
1717

1818
.PHONY: e2e-tests-ci
19-
e2e-tests-ci: build
19+
e2e-tests-ci:
2020
docker-compose build app-for-e2e test-e2e
2121
# "-" means continue running commands even if they error (failed tests)
2222
-docker-compose run -e GITHUB_ACTIONS=1 --name e2etests test-e2e

docker/app/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ FROM sillsdev/web-languageforge:base-php AS production-app
5353
RUN rm /usr/local/bin/install-php-extensions
5454
RUN apt-get remove -y gnupg2
5555
RUN mv $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
56+
# had to add /wait into prod image so the prod image could be run through E2E tests.
57+
COPY --from=sillsdev/web-languageforge:wait-latest /wait /wait
5658

5759
# DEVELOPMENT IMAGE
5860
FROM sillsdev/web-languageforge:base-php AS development-app
@@ -62,8 +64,7 @@ RUN mv $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini
6264
COPY --from=sillsdev/web-languageforge:wait-latest /wait /wait
6365

6466
FROM ${ENVIRONMENT}-app AS languageforge-app
65-
ARG BUILD_VERSION=9.9.9
66-
ENV BUILD_VERSION=${BUILD_VERSION}
67+
ARG BUILD_VERSION=${BUILD_VERSION:-'9.9.9'}
6768

6869
# copy app into image
6970
COPY src /var/www/html/

docker/deployment/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
*-current.yaml
2+
all_projects
3+
on_hold

0 commit comments

Comments
 (0)