Skip to content

Commit

Permalink
Use public docker images instead of building locally (#82)
Browse files Browse the repository at this point in the history
* don't build docker images when starting

* build docker images using frontend&backend scripts

* fix start script to just use docker-compose.yml

* update docker compose files to use public docker images

* stop script to use docker-compose.yml directly

* record backend sha moved into backend Dockerfile

* frontend docker build script in same location

* remove deleted record-backend-sha-version.sh script from start.sh
  • Loading branch information
mikaelhm authored Nov 7, 2023
1 parent 7ccf2df commit 9be50e8
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 100 deletions.
5 changes: 3 additions & 2 deletions docker-compose.override-backend-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
version: "3.3"
services:
backend:
command: bash -c "./prestart.sh; while true; do sleep 1; done" # Infinite loop to keep container live doing nothing
command: bash -c "poetry install --no-root; ./prestart.sh; while true; do sleep 1; done" # Infinite loop to keep container live doing nothing
volumes:
- ./:/app
environment:
- PYTHONPATH=/app/backend
working_dir: /app/backend
build:
context: ./backend
args:
INSTALL_DEV: "true"
INSTALL_DEV: ${INSTALL_DEV-true}
2 changes: 2 additions & 0 deletions docker-compose.override-frontend-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ services:
working_dir: /app/frontend
command: bash -c "npm install && while true; do sleep 1; done" # Infinite loop to keep container live doing nothing
build:
context: ./frontend
args:
INSTALL_DEV: ${INSTALL_DEV-true}
FRONTEND_ENV: dev
INSTALL_PUPPETEER: ${INSTALL_PUPPETEER-false}
15 changes: 4 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ services:
- node.labels.${STACK_NAME?Variable not set}.app-db-data == true

backend:
image: 'backend:latest'
image: 'ghcr.io/project-chip/csa-certification-tool-backend:latest'
ports:
- "8888:8888"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- /var/run/dbus:/var/run/dbus
- ./backend:/app # mount code in container
- ./backend/test_collections:/app/test_collections # mount test_collections in container
depends_on:
- db
env_file:
Expand All @@ -88,24 +88,17 @@ services:
privileged: true
build:
context: ./backend
dockerfile: backend.dockerfile
args:
INSTALL_DEV: ${INSTALL_DEV-false}
command: /start-reload.sh
command: /start.sh
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`)
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=80

frontend:
image: 'frontend:latest'
image: 'ghcr.io/project-chip/csa-certification-tool-frontend'
build:
context: ./frontend
args:
FRONTEND_ENV: dev
INSTALL_PUPPETEER: ${INSTALL_PUPPETEER-false}
INSTALL_DEV: ${INSTALL_DEV-false}
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
Expand Down
25 changes: 0 additions & 25 deletions scripts/build-no-cache.sh

This file was deleted.

9 changes: 2 additions & 7 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,5 @@
# Exit in case of error
set -e

# Ensure .env exists
./scripts/install-default-env.sh

FRONTEND_ENV=${FRONTEND_ENV-production} \
docker-compose \
-f docker-compose.yml \
build
./backend/scripts/build-docker-image.sh "$@"
./frontend/scripts/build-docker-image.sh "$@"
35 changes: 0 additions & 35 deletions scripts/record-backend-sha-version.sh

This file was deleted.

21 changes: 2 additions & 19 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ set -e
# Ensure .env exists
./scripts/install-default-env.sh

# Record Backend SHA to a file
sh ./scripts/record-backend-sha-version.sh

# Dev override files
BACKEND_COMPOSE="-f docker-compose.override-backend-dev.yml"
FRONTEND_COMPOSE="-f docker-compose.override-frontend-dev.yml"
Expand All @@ -54,29 +51,15 @@ do
DEV_COMPOSE_FILES="$DEV_COMPOSE_FILES $FRONTEND_COMPOSE"
shift # Remove --frontend from processing
;;
--build-no-cache)
COMPOSE_CACHE_OPTION="--no-cache"
shift # Remove --build-no-cache from processing
;;
*)
OTHER_ARGUMENTS+=("$1")
shift # Remove generic argument from processing
;;
esac
done


docker-compose \
-f docker-compose.yml \
$DEV_COMPOSE_FILES \
config > docker-stack.yml

if [ ! -z "$COMPOSE_CACHE_OPTION" ] ; then
echo "Building no-cache"
docker-compose -f docker-stack.yml build $COMPOSE_CACHE_OPTION
fi

docker-compose -f docker-stack.yml up -d
# Start docker containers with docker-compose
docker-compose -f docker-compose.yml $DEV_COMPOSE_FILES up -d

if [ "$FRONTEND_DEV" = true ] ; then
echo "!!!! Matter TH frontend started in development mode."
Expand Down
2 changes: 1 addition & 1 deletion scripts/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ ROOT_DIR=$(realpath $(dirname "$0")/..)
cd $ROOT_DIR
# Exit in case of error
set -e
docker-compose -f docker-stack.yml down
docker-compose -f docker-compose.yml down

0 comments on commit 9be50e8

Please sign in to comment.