Skip to content

Commit

Permalink
Merge branch '116-frontend-add-unit-testing-for-frontend' into vitest…
Browse files Browse the repository at this point in the history
…-branch
  • Loading branch information
kristo-baricevic authored Apr 13, 2024
2 parents 8a935d7 + 091a576 commit 5542a6e
Show file tree
Hide file tree
Showing 9,200 changed files with 1,684,756 additions and 636 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
69 changes: 0 additions & 69 deletions .github/workflows/containers-publish.yml
Original file line number Diff line number Diff line change
@@ -1,69 +0,0 @@
name: "Containers: Publish"

on:
push:
tags: ["v*"]

permissions:
packages: write

jobs:
release-containers:
name: Build and Push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Login to ghcr.io Docker registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Compute Docker container image addresses
run: |
DOCKER_REPOSITORY="ghcr.io/${GITHUB_REPOSITORY,,}"
DOCKER_TAG="${GITHUB_REF:11}"
echo "DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" >> $GITHUB_ENV
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
echo "Using: ${DOCKER_REPOSITORY}/*:${DOCKER_TAG}"
# - name: 'Pull previous Docker container image: :latest'
# run: docker pull "${DOCKER_REPOSITORY}:latest" || true

- name: "Pull previous Docker container image: frontend-static:latest"
run: docker pull "${DOCKER_REPOSITORY}/frontend-static:latest" || true

- name: "Build Docker container image: frontend-static:latest"
run: |
docker build \
--cache-from "${DOCKER_REPOSITORY}/frontend-static:latest" \
--file frontend/Dockerfile.demo \
--build-arg SERVER_NAME=localhost \
--tag "${DOCKER_REPOSITORY}/frontend-static:latest" \
--tag "${DOCKER_REPOSITORY}/frontend-static:${DOCKER_TAG}" \
frontend
- name: "Push Docker container image frontend-static:latest"
run: docker push "${DOCKER_REPOSITORY}/frontend-static:latest"

- name: "Push Docker container image frontend-static:v*"
run: docker push "${DOCKER_REPOSITORY}/frontend-static:${DOCKER_TAG}"
#
#
# - name: 'Build Docker container image: backend:latest'
# run: |
# cd backend && \
# make && \
# docker image tag "${DOCKER_REPOSITORY}/backend/local:latest" "${DOCKER_REPOSITORY}/backend:latest"
#
# - name: Push Docker container image backend:latest
# run: docker push "${DOCKER_REPOSITORY}/backend:latest"
#
# - name: Push Docker container image backend:v*
# run: docker push "${DOCKER_REPOSITORY}/backend:${DOCKER_TAG}"

# - name: Push Docker container image :v*"
# run: docker push "${DOCKER_REPOSITORY}:${DOCKER_TAG}"
18 changes: 0 additions & 18 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
@@ -1,18 +0,0 @@
name: "Release: Prepare PR"

on:
push:
branches: [develop]

permissions:
contents: read
pull-requests: write

jobs:
release-prepare:
runs-on: ubuntu-latest
steps:
- uses: JarvusInnovations/infra-components@channels/github-actions/release-prepare/latest
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
release-branch: main
14 changes: 0 additions & 14 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
@@ -1,14 +0,0 @@
name: "Release: Publish PR"

on:
pull_request:
branches: [main]
types: [closed]

jobs:
release-publish:
runs-on: ubuntu-latest
steps:
- uses: JarvusInnovations/infra-components@channels/github-actions/release-publish/latest
with:
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
14 changes: 0 additions & 14 deletions .github/workflows/release-validate.yml
Original file line number Diff line number Diff line change
@@ -1,14 +0,0 @@
name: "Release: Validate PR"

on:
pull_request:
branches: [main]
types: [opened, edited, reopened, synchronize]

jobs:
release-validate:
runs-on: ubuntu-latest
steps:
- uses: JarvusInnovations/infra-components@channels/github-actions/release-validate/latest
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Empty file added Dockerfile.prod
Empty file.
8 changes: 8 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
'@babel/preset-react',
],
};

1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gateway: 192.168.0.1
21 changes: 21 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,24 @@ services:
image: postgres:15
volumes:
- postgres_data:/var/lib/postgresql/data/
<<<<<<< HEAD
env_file:
<<<<<<< HEAD
- ./config/env/env.prod.db
=======
- ./config/env/.env.prod.db
>>>>>>> ac68347c12ced724206112843623ee8c515bd3ad
backend:
build:
context: ./server
dockerfile: Dockerfile.prod
command: gunicorn balancer_backend.wsgi:application --bind 0.0.0.0:8000
=======
environment:
- POSTGRES_USER=balancer
- POSTGRES_PASSWORD=balancer
- POSTGRES_DB=balancer_dev
>>>>>>> 5d9968afe8f5ab373ab0379485cea79ba3253193
ports:
- "5432:5432"
backend:
Expand All @@ -18,9 +32,15 @@ services:
ports:
- "8000:8000"
env_file:
<<<<<<< HEAD
- ./config/env/env.prod
=======
- ./config/env/env.dev
>>>>>>> 5d9968afe8f5ab373ab0379485cea79ba3253193
depends_on:
- db
<<<<<<< HEAD
=======
frontend:
image: balancer-frontend
build:
Expand All @@ -38,6 +58,7 @@ services:
- "/usr/src/app/node_modules/"
depends_on:
- backend
>>>>>>> ac68347c12ced724206112843623ee8c515bd3ad

volumes:
postgres_data:
74 changes: 0 additions & 74 deletions docker-compose.yml

This file was deleted.

2 changes: 0 additions & 2 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ config/env/env.dev
*.njsproj
*.sln
*.sw?

.DS_Store
38 changes: 38 additions & 0 deletions frontend/Dockerfile.demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This dockerfile builds an image for a static frontend only server suitable for online hosting.
# Use the official Node.js image as the base image
FROM node:18 as builder

# Set the working directory inside the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json
COPY package*.json ./

# Set version number
ARG FRONTEND_VERSION
RUN npm version $FRONTEND_VERSION

# Install dependencies
RUN npm ci --legacy-peer-deps

# Copy project files
COPY . .

RUN npm run build

FROM alpine:latest as nginx-config
RUN apk --no-cache add gettext
WORKDIR /app
COPY nginx.conf.demo ./nginx.conf.demo
# This will get overwritten by helm chart

ARG SERVER_NAME
ENV SERVER_NAME $SERVER_NAME
RUN cat nginx.conf.demo | envsubst > nginx.conf

FROM nginx:alpine

COPY --from=nginx-config /app/nginx.conf /etc/nginx/nginx.conf
COPY --from=Builder /usr/src/app/dist /usr/share/nginx/html

# The default entrypoint works for us.
9 changes: 5 additions & 4 deletions frontend/Dockerfile → frontend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Use the official Node.js 14 image as the base image
# This dockerfile builds an image for a Vite development server
# Use the official Node.js image as the base image
FROM node:18

# Set the working directory inside the container
Expand All @@ -14,12 +15,12 @@ RUN npm install
COPY . .

# Build the project
RUN npm run build
# RUN npm run build

# Expose a port if required
EXPOSE 3000
# EXPOSE 3000

# Start the application
# Start the dev server
CMD [ "npm", "run", "dev" ]

# Set the image name
Expand Down
16 changes: 16 additions & 0 deletions frontend/docker-compose.demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.8"
services:
frontend-static:
build:
context: .
dockerfile: Dockerfile.demo
args:
- IMAGE_NAME=frontend-static
- FRONTEND_VERSION=0.0.2
- SERVER_NAME=localhost
image: ghcr.io/codeforphilly/balancer-main/frontend-static:0.0.2
ports:
- "80:80"
environment:
- CHOKIDAR_USEPOLLING=true
- VITE_API_BASE_URL=https://devnull-as-a-service.com/dev/null
16 changes: 16 additions & 0 deletions frontend/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.8"
services:
react-app:
build:
context: .
dockerfile: Dockerfile.dev
args:
- IMAGE_NAME=balancer-frontend-dev
ports:
- "3000:3000"
# The port number is hard-coded, located in ./vite.config.ts
environment:
- CHOKIDAR_USEPOLLING=true
volumes:
- "./:/usr/src/app:delegated"
- "./node_modules:/usr/src/app/node_modules/"
29 changes: 29 additions & 0 deletions frontend/nginx.conf.demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# nginx config file for static frontend demo site.
# This will be the nginx.conf in the docker image before it gets overwritten by kubernetes helm chart.
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
server {
listen 80;
listen [::]:80;
server_name $SERVER_NAME;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
6 changes: 6 additions & 0 deletions frontend/src/config/envConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const getEnv = () => {
return {
apiUrl: import.meta.env.VITE_API_BASE_URL,
};
};

Loading

0 comments on commit 5542a6e

Please sign in to comment.