Skip to content

A simple Gatsby wiki with GitHub Actions, Azure App Service container and Google authentication (log in with Gmail)

License

Notifications You must be signed in to change notification settings

codesanook/my-company-wiki

Repository files navigation

my-company-wiki

A simple Gatsby wiki with GitHub Actions, Azure App Service container and Google authentication (log in with Gmail)

How to run the project locally

  • CD to the root of the project
  • Install all required NPM packages
    $ yarn
  • Start Gatsby in development mode
    $ yarn start

Test a container locally

  • Use the following commands to test a Docker container
    $ docker build --tag wiki-image --no-cache .
    $ docker run --rm --env-file .env --publish 8000:8000 --name wiki wiki-image
    $ docker stop wiki
    $ docker exec -it wiki /bin/sh

Deploy to Azure App Service Container

Create DockerHub repository and get a new token

  • Create a private DockerHub repository.
  • Get DockerHub token from Account Settings > Security > New Access Token.

Create a new App Service

  • Create a new Azure App Service with a container.
  • Use Docker Hub registry and select mcr.microsoft.com/dotnet/samples:aspnetapp image
  • Check deployment logging.
  • Open a browser and navigate to https://[YOUR_APP_SERVICE_NAME].azurewebsites.net/
  • You should find an example of ASP.NET Core MVC app.
  • Example of Azure CLI to create a new Azure App Service Container:
    az webapp create \
      --name [YOUR_APP_SERVICE_NAME] \
      --resource-group [YOUR_RESOURCE_GROUP_NAME] \
      --plan [YOUR_APP_SERVICE_PLAN] \
      --deployment-container-image-name mcr.microsoft.com/dotnet/samples:aspnetapp

Set some configurations

  • Set these configurations to your app service:
    • WEBSITE_WEBDEPLOY_USE_SCM
      • true
    • WEBSITES_PORT
      • 8000
    • OAUTH2_CLIENT_ID
      • Set value to your Google Oauth2 client ID.
    • OAUTH2_CLIENT_SECRET
      • Set value to your Google Oauth2 client secret.
    • OAUTH2_REDIRECT_URL
      • Set value to your public website redirect URL. It is usually in: https://[YOUR_APP_SERVICE_NAME].azurewebsites.net/oauth2/callback
    • DOCKER_REGISTRY_SERVER_URL
      • index.docker.io
    • DOCKER_REGISTRY_SERVER_USERNAME
      • Your
    • DOCKER_REGISTRY_SERVER_PASSWORD
      • Your ACR password

Create GitHub secret keys and values

  • Create these GitHub secrets with their values:
    • AZURE_WEBAPP_CONTAINER_PUBLISH_PROFILE
      • Download publish profile from your App Service and use it as a value of AZURE_WEBAPP_CONTAINER_PUBLISH_PROFILE secret.
    • AZURE_WEBAPP_NAME
      • Your app service name, only name, no https:// or .azurewebsites.net.
    • DOCKER_HUB_REPOSITORY
      • Your Docker Hub project repository name
    • DOCKER_HUB_USERNAME
      • Your Docker Hub username
    • DOCKER_HUB_TOKEN
      • Your Docker Hub access token
    • AUTHENTICATED_EMAILS
      • authenticated emails in base64 format which containers each line per an email.
      • It can be created as $ cat filename | base64

Trigger GitHub Actions

  • Go to GitHub Action tab and enable it
  • Create new commit and push the project to the main branch

Add test users and set redirect URL

Presentation

PRO

  • Protected website with Gmail authentication
  • Markdown & MDX (React component)
  • Theme shadowing

CON

  • You need to create a link to a page manually, not automatically discover.
  • Not realtime deployment and wait 3-4 minutes for each deployment.

Trouble shooting

  • To start login over again, clear cookie and ctrl+f5
  • Configuration not load and no value in docker run
  • Restart a website and make http request.
  • Error: Deployment Failed with Error: Error: Failed to get app runtime OS
    • It can be from an invalid publish profile.

DEMO site

TODO

  • Improve code quality
  • Use async/await

About

A simple Gatsby wiki with GitHub Actions, Azure App Service container and Google authentication (log in with Gmail)

Resources

License

Stars

Watchers

Forks