Skip to content

Commit

Permalink
Move to GitHub Actions and Azure App Service (#119)
Browse files Browse the repository at this point in the history
* configure reverse proxy to initializr service with uri/host being set by env vars
  • Loading branch information
TimHess authored Feb 9, 2024
1 parent 5d16762 commit 567e6ec
Show file tree
Hide file tree
Showing 34 changed files with 124 additions and 772 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and deploy

on:
pull_request:
branches:
- main
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: 'read'
pull-requests: 'write'

env:
IMAGE_TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.run_id }}

jobs:
build-push-deploy:
name: Build and push image
environment:
name: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || vars.STAGING_SLOT_NAME }}
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
env:
SLOT_NAME: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || vars.STAGING_SLOT_NAME }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Login to container registry
uses: azure/docker-login@v1
with:
login-server: "${{ vars.DOCKER_REGISTRY }}"
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"

- name: Build image
run: docker build . --file "Dockerfile" -t ${{ vars.DOCKER_REGISTRY }}/initializr-web:${{ env.IMAGE_TAG }}

- name: Push image
run: docker push ${{ vars.DOCKER_REGISTRY }}/initializr-web:${{ env.IMAGE_TAG }}

- name: If PR, create a new staging slot
if: ${{ github.event_name == 'pull_request' }}
run: az webapp deployment slot create --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} --name ${{ vars.AZURE_WEBAPP_NAME}} --slot ${{ env.SLOT_NAME }} --configuration-source staging

- name: Deploy to staging slot
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
images: ${{ vars.DOCKER_REGISTRY }}/initializr-web:${{ env.IMAGE_TAG }}
slot-name: ${{ env.SLOT_NAME }}

- name: If PR, comment with the preview link
if: ${{ github.event_name == 'pull_request' }}
uses: mshick/add-pr-comment@v2
with:
message: |
## Preview link: https://${{ vars.AZURE_WEBAPP_NAME }}-${{ env.SLOT_NAME }}.azurewebsites.net
- Your changes have been deployed to the preview site. The preview site will update as you add more commits to this branch.
- The preview link is shareable, but will be deleted when the pull request is merged or closed.
> *This is an automated message.*
repo-token: ${{ secrets.GITHUB_TOKEN }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ target
.DS_Store

/tools/
.vscode/settings.json
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ RUN yarn build
FROM phusion/passenger-nodejs:3.0.1
COPY --from=build /usr/src /usr/share/initializr/www
RUN chown -R app:app /usr/share/initializr/www
RUN apt-get update && apt-get install -y gettext-base
RUN rm /etc/nginx/sites-enabled/default
RUN rm -f /etc/service/nginx/down
COPY deploy/docker/initializr-web.conf /etc/nginx/sites-enabled/
RUN sed -i "s|daemon off;|#daemon off; |g" /etc/nginx/nginx.conf
RUN echo "env INITIALIZR_SERVICE_HOST;" >> /etc/nginx/main.d/default.conf
RUN echo "env INITIALIZR_SERVICE_URI;" >> /etc/nginx/main.d/default.conf
COPY deploy/docker/initializr-web.conf.template /etc/nginx/templates/
COPY deploy/docker/docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
ENTRYPOINT [ "./docker-entrypoint.sh" ]
CMD ["nginx", "-g", "daemon off;"]

# cat /etc/nginx/sites-enabled/initializr.conf
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Steeltoe Initializr UI reference implementation

[![Build Status](https://dev.azure.com/SteeltoeOSS/Steeltoe/_apis/build/status/Initializr/SteeltoeOSS.InitializrWeb?branchName=main)](https://dev.azure.com/SteeltoeOSS/Steeltoe/_build/latest?definitionId=32&branchName=main)

## About

This implementation largely steals from the [Spring Initializr Client](https://github.com/spring-io/start.spring.io).
Expand All @@ -14,9 +12,10 @@ Domain metadata include metadata differences such as "Java version" vs ".NET Fra
## Deploying

There are 2 endpoints that the Web UI uses to 1) populate its UI, and 2) generate projects:

* `/api/config/projectMetadata`
* `/api/project`

For local development, these endpoints are implemented in the development webpack configuration in [start-client/webpack.dev.js](start-client/webpack.dev.js).

In a remote deployment, those endpoints are implemented by the [Initializr API](https://github.com/SteeltoeOSS/InitializrApi).
Expand Down
65 changes: 0 additions & 65 deletions azure-pipelines.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions ci/README.adoc

This file was deleted.

45 changes: 0 additions & 45 deletions ci/config/deployment.yml

This file was deleted.

3 changes: 0 additions & 3 deletions ci/config/elastic.yml

This file was deleted.

9 changes: 0 additions & 9 deletions ci/config/kubeconfig.yml

This file was deleted.

7 changes: 0 additions & 7 deletions ci/config/secret.yml

This file was deleted.

21 changes: 0 additions & 21 deletions ci/images/README.adoc

This file was deleted.

25 changes: 0 additions & 25 deletions ci/images/setup.sh

This file was deleted.

21 changes: 0 additions & 21 deletions ci/images/start-site-ci-image/Dockerfile

This file was deleted.

22 changes: 0 additions & 22 deletions ci/parameters.yml

This file was deleted.

Loading

0 comments on commit 567e6ec

Please sign in to comment.