This repository contains a frontend application built with Vue.js. It includes a GitHub Actions workflow that builds a Docker image and automatically deploys it to a Google Kubernetes Engine (GKE) cluster whenever there is a push to the main branch, which is protected to prevent direct commits and enforce pull requests.
The .github/workflows/build.yml file defines a GitHub Action that performs the following steps:
- Checkout the code: Retrieves the source code from the
mainbranch. - Authenticate with GCP: Uses a service account (
GCP_SA_CREDENTIALS) to authenticate with Google Cloud. - Set up GCP SDK: Installs and configures the
gcloudCLI. - Configure Docker with Artifact Registry: Allows Docker to push images to GCP’s container registry.
- Get GKE credentials: Connects to the GKE cluster to run
kubectlcommands. - Set image tag: Generates a unique image tag per commit using the branch name and timestamp.
- Build Docker image: Builds and tags the Docker image with both the generated tag and
latest. - Push the image: Pushes both
latestand timestamped tags to GCP's Artifact Registry. - Update deployment on GKE: If a deployment named
frontendexists, it updates the container image forfrontend-container.
.
├── src/ # Frontend source code (Vue.js)
├── build/ # Webpack config and build utilities
├── config/ # Environment configurations (dev/prod)
├── Dockerfile # Docker image used in the pipeline
└── .github/workflows/ # GitHub Actions workflows
To make the workflow run successfully, you need to set up the following in your GitHub repository:
GCP_SA_CREDENTIALS: JSON with credentials for a service account that has permissions for:- Artifact Registry
- GKE (get-credentials and set image)
GCP_PROJECT: Google Cloud project IDGKE_CLUSTER: Name of your GKE cluster
GCP_ZONE: Zone where the cluster is located (e.g.us-central1)REGISTRY: Artifact Registry repository name (e.g.my-registry)IMAGE_NAME: Name of the image to be built (e.g.frontend)
This project includes a Dockerfile that packages the Vue.js app for production. Make sure the Dockerfile is properly configured for your production environment.
UI for sample distributed TODO application.
PORT- a port the application binds toAUTH_API_ADDRESS- address ofauth-apifor authenticationTODOS_API_ADDRESS- address oftodos-apifor TODO CRUD
# install dependencies
npm install
# build application
npm run buildPORT=8080 AUTH_API_ADDRESS=http://127.0.0.1:8000 TODOS_API_ADDRESS=http://127.0.0.1:8082 npm startHere you can find the software required to run this microservice, as well as the version we have tested.
| Dependency | Version |
|---|---|
| Node | 8.17.0 |
| NPM | 6.13.4 |