Skip to content

Commit

Permalink
Merge branch 'main' into listOfMed
Browse files Browse the repository at this point in the history
  • Loading branch information
kristo-baricevic authored Feb 22, 2024
2 parents b727f6a + 7761fc2 commit fb4e501
Show file tree
Hide file tree
Showing 21 changed files with 402 additions and 25 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/containers-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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}"
20 changes: 20 additions & 0 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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
16 changes: 16 additions & 0 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 }}
16 changes: 16 additions & 0 deletions .github/workflows/release-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 }}
16 changes: 12 additions & 4 deletions server/Dockerfile.prod → Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# This image runs the production server, with nginx
###########
# BUILDER #
###########

# pull official base image
FROM python:3.11.4-slim-buster as builder
FROM python:3.11.4-slim-buster as python_builder

# set work directory
WORKDIR /usr/src/app
Expand Down Expand Up @@ -48,8 +49,8 @@ WORKDIR $APP_HOME

# install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends netcat
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
COPY --from=python_builder /usr/src/app/wheels /wheels
COPY --from=python_builder /usr/src/app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*

Expand All @@ -68,4 +69,11 @@ RUN chown -R app:app $APP_HOME
USER app

# run entrypoint.prod.sh
ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"]
<<<<<<< HEAD:Dockerfile.prod
ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"]


# TODO: gunicorn stuff
=======
ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"]
>>>>>>> ac68347c12ced724206112843623ee8c515bd3ad:server/Dockerfile.prod
13 changes: 0 additions & 13 deletions config/env/env.dev

This file was deleted.

9 changes: 8 additions & 1 deletion docker-compose.yml → docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ services:
backend:
image: balancer-backend
build: ./server
<<<<<<< HEAD:docker-compose.dev.yml
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./server:/usr/src/app
=======
>>>>>>> ed1b2e3bc80a77cb1283844d0c153fa1f79d9d76:docker-compose.yml
ports:
- "8000:8000"
env_file:
Expand All @@ -21,9 +27,10 @@ services:
image: balancer-frontend
build:
context: frontend
dockerfile: Dockerfile
dockerfile: Dockerfile.dev
args:
- IMAGE_NAME=balancer-frontend
- FRONTEND_VERSION=0.0.1
ports:
- "3001:3001"
environment:
Expand Down
9 changes: 8 additions & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ services:
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
<<<<<<< HEAD
- ./config/env/env.prod.db
=======
- ./config/env/.env.prod.db
>>>>>>> ac68347c12ced724206112843623ee8c515bd3ad
backend:
build:
context: ./server
Expand All @@ -14,9 +18,11 @@ services:
ports:
- 8000:8000
env_file:
- ./config/env/.env.prod
- ./config/env/env.prod
depends_on:
- db
<<<<<<< HEAD
=======
frontend:
build:
context: ./frontend
Expand All @@ -25,6 +31,7 @@ services:
- "3000:80"
depends_on:
- backend
>>>>>>> ac68347c12ced724206112843623ee8c515bd3ad

volumes:
postgres_data:
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;
}
}
}
9 changes: 9 additions & 0 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: nginx-helm-chart
description: A generated Helm Chart for nginx-helm-chart from Skippbox Kompose
version: 0.0.2
apiVersion: v2
keywords:
- nginx-helm-chart
sources:
- https://github.com/CodeForPhilly/balancer-main
home: https://opencollective.com/code-for-philly/projects/balancer
2 changes: 2 additions & 0 deletions helm-chart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Chart initially created by Kompose from nginx-docker-compose.yml

Loading

0 comments on commit fb4e501

Please sign in to comment.