Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinguy committed Jul 5, 2024
1 parent 2e1265d commit 5370ec7
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 40 deletions.
72 changes: 35 additions & 37 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,59 @@
steps:
# Step to set up Docker Buildx
- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'create', '--name', 'mybuilder']

- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'use', 'mybuilder']

- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'inspect', '--bootstrap']

# Step to authenticate to Google Cloud Container Registry (GCR)
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud auth configure-docker
args: ['gcloud', 'auth', 'configure-docker']

# Steps to build and push Docker images for each service
- name: 'gcr.io/cloud-builders/docker'
id: Build server image
id: Build and push server image
args:
[
'build',
'-t',
'gcr.io/$PROJECT_ID/betterscan-server:latest',
'-f',
'docker/docker/backend/Dockerfile',
'docker/docker/backend'
'buildx', 'build', '.',
'--platform', 'linux/amd64,linux/arm64',
'--tag', 'gcr.io/$PROJECT_ID/betterscan-server:amd64-latest',
'--tag', 'gcr.io/$PROJECT_ID/betterscan-server:arm64-latest',
'--tag', 'gcr.io/$PROJECT_ID/betterscan-server:latest',
'--push',
'--file', 'docker/docker/backend/Dockerfile'
]

- name: 'gcr.io/cloud-builders/docker'
id: Push server image latest
args: ['push', 'gcr.io/$PROJECT_ID/betterscan-server:latest']

- name: 'gcr.io/cloud-builders/docker'
id: Build worker image
id: Build and push worker image
args:
[
'build',
'-t',
'gcr.io/$PROJECT_ID/betterscan-worker:latest',
'-f',
'docker/docker/worker/Dockerfile',
'docker/docker/worker'
'buildx', 'build', '.',
'--platform', 'linux/amd64,linux/arm64',
'--tag', 'gcr.io/$PROJECT_ID/betterscan-worker:amd64-latest',
'--tag', 'gcr.io/$PROJECT_ID/betterscan-worker:arm64-latest',
'--tag', 'gcr.io/$PROJECT_ID/betterscan-worker:latest',
'--push',
'--file', 'docker/docker/worker/Dockerfile'
]

- name: 'gcr.io/cloud-builders/docker'
id: Push worker image latest
args: ['push', 'gcr.io/$PROJECT_ID/betterscan-worker:latest']

- name: 'gcr.io/cloud-builders/docker'
id: Build worker-cli image
id: Build and push worker-cli image
args:
[
'build',
'-t',
'gcr.io/$PROJECT_ID/betterscan-worker-cli:latest',
'-f',
'docker/docker/worker-cli/Dockerfile',
'docker/docker/worker-cli'
'buildx', 'build', '.',
'--platform', 'linux/amd64,linux/arm64',
'--tag', 'gcr.io/$PROJECT_ID/betterscan-worker-cli:amd64-latest',
'--tag', 'gcr.io/$PROJECT_ID/betterscan-worker-cli:arm64-latest',
'--tag', 'gcr.io/$PROJECT_ID/betterscan-worker-cli:latest',
'--push',
'--file', 'docker/docker/worker-cli/Dockerfile'
]

- name: 'gcr.io/cloud-builders/docker'
id: Push worker-cli image latest
args: ['push', 'gcr.io/$PROJECT_ID/betterscan-worker-cli:latest']

images:
- 'gcr.io/$PROJECT_ID/betterscan-server:latest'
- 'gcr.io/$PROJECT_ID/betterscan-worker:latest'
Expand Down
2 changes: 1 addition & 1 deletion docker/docker/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG DEBIAN_FRONTEND=noninteractive
FROM python:3.8
FROM python:3.8-slim

# Set timezone and environment variables
ENV CONTAINER_TIMEZONE=UTC
Expand Down
2 changes: 1 addition & 1 deletion docker/docker/worker-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.8-slim

ARG DEBIAN_FRONTEND=noninteractive
ENV CONTAINER_TIMEZONE=UTC
Expand Down
2 changes: 1 addition & 1 deletion docker/docker/worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG DEBIAN_FRONTEND=noninteractive
FROM python:3.8
FROM python:3.8-slim

# Set environment variables for timezone and non-interactive installs
ENV CONTAINER_TIMEZONE=UTC
Expand Down
17 changes: 17 additions & 0 deletions gcrio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Setup

# For amd64
export ARCH=amd64
docker-compose up

# For arm64
export ARCH=arm64
docker-compose up


Go in the Bowser to:

`http://localhost:5000`

Signup up and login to use your local installation.

85 changes: 85 additions & 0 deletions gcrio/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
version: '3.8'

x-platform: &platform
platform: ${PLATFORM:-linux/amd64}

services:
server:
image: gcr.io/YOUR_PROJECT_ID/betterscan-server:${ARCH:-amd64}-latest
restart: always
environment:
LIC:
OPENAI_GPT_API:
depends_on:
- postgres
working_dir: /srv/betterscan/
entrypoint: sh
command: -c "mkdir -p data1/repositories data2/tasks setup_state && if [ -f /srv/betterscan/setup_state/setup_done ]; then python3.8 /srv/betterscan/manage.py runserver; else python3.8 /srv/betterscan/manage.py setup && touch /srv/betterscan/setup_state/setup_done; fi"
ports:
- 5001:5000
volumes:
- ./data1:/srv/betterscan/quantifiedcode/data/
- ./data2:/srv/betterscan/quantifiedcode/backend/data/tasks
- ./setup_state:/srv/betterscan/setup_state
links:
- "postgres"
<<: *platform

postgres:
image: postgres:13.2
restart: always
environment:
POSTGRES_DB: qc
POSTGRES_USER: qc
POSTGRES_PASSWORD: qc
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
volumes:
- db-data:/var/lib/postgresql/data

worker_1:
image: gcr.io/YOUR_PROJECT_ID/betterscan-worker:${ARCH:-amd64}-latest
ulimits:
stack: -1
restart: always
environment:
LIC:
SNYK_TOKEN:
OPENAI_GPT_API:
hostname: worker_1
depends_on:
- rabbitmq3
- postgres
- server
working_dir: /srv/betterscan/
entrypoint: sh
command: -c "python3.8 /srv/betterscan/manage.py runworker"
volumes:
- ./data1:/srv/betterscan/quantifiedcode/data/
- ./data2:/srv/betterscan/quantifiedcode/backend/data/tasks
links:
- "rabbitmq3"
- "server"
- "postgres"
<<: *platform

rabbitmq3:
container_name: "rabbitmq"
image: rabbitmq:3.8-management-alpine
environment:
- RABBITMQ_DEFAULT_USER=qc
- RABBITMQ_DEFAULT_PASS=qc
ports:
- 5672:5672
- 15672:15672
healthcheck:
test: [ "CMD", "nc", "-z", "localhost", "5672" ]
interval: 5s
timeout: 15s
retries: 1

volumes:
db-data:
driver: local

0 comments on commit 5370ec7

Please sign in to comment.