add postgresql container to run tests in
All checks were successful
test-backend / test-x86_64 (push) Successful in 22s
All checks were successful
test-backend / test-x86_64 (push) Successful in 22s
This commit is contained in:
parent
393b426e85
commit
642c1fa944
29
.gitea/workflows/test-backend.yaml
Normal file
29
.gitea/workflows/test-backend.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
name: test-backend
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
test-x86_64:
|
||||
runs-on: alpine
|
||||
steps:
|
||||
- name: Install tools for testing
|
||||
shell: sh
|
||||
run: |
|
||||
apk --update add git docker docker-compose postgresql
|
||||
- name: Pull postgres docker image
|
||||
shell: sh
|
||||
run: docker pull postgres
|
||||
- name: Pull custom docker image
|
||||
shell: sh
|
||||
run: docker pull 10.5.1.5:5000/sdlc/x86_64
|
||||
- name: Pull repository
|
||||
shell: sh
|
||||
run: |
|
||||
git init
|
||||
git remote add gitea http://10.1.1.1:3000/hasslesstech/sdlc-project
|
||||
git fetch gitea
|
||||
git checkout gitea/master
|
||||
- name: Deploy testing environment
|
||||
shell: sh
|
||||
run: docker-compose -f backend/docker-compose-x86_64.yaml up -d
|
@ -1,13 +0,0 @@
|
||||
FROM cmosh/alpine-arm AS build
|
||||
|
||||
RUN apk --update add python3
|
||||
RUN mkdir /venv /app
|
||||
RUN python3 -m venv /venv
|
||||
ENV PATH="/venv/bin:$PATH"
|
||||
|
||||
RUN apk add build-base linux-headers musl-dev python3-dev libpq-dev
|
||||
RUN pip3 install flask uwsgi psycopg2
|
||||
|
||||
EXPOSE 9090/tcp
|
||||
|
||||
ENTRYPOINT ["uwsgi", "--http", ":9090", "--callable", "app", "--wsgi-file", "/app/main.py"]
|
37
backend/docker-compose-x86_64.yaml
Normal file
37
backend/docker-compose-x86_64.yaml
Normal file
@ -0,0 +1,37 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DB=postgres
|
||||
networks:
|
||||
- testing
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||
interval: 10s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
timeout: 3s
|
||||
|
||||
backend:
|
||||
image: 10.5.1.5:5000/sdlc/x86_64
|
||||
ports:
|
||||
- "80:9090"
|
||||
volumes:
|
||||
- "./src/:/app:ro"
|
||||
environment:
|
||||
- DB_NAME=postgres
|
||||
- DB_USER=postgres
|
||||
- DB_PASS=postgres
|
||||
- DB_HOST=postgres
|
||||
- DB_PORT=5432
|
||||
networks:
|
||||
- testing
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
# restart: true
|
||||
|
||||
networks:
|
||||
testing:
|
@ -1,8 +0,0 @@
|
||||
services:
|
||||
backend:
|
||||
build: .
|
||||
ports:
|
||||
- "80:9090"
|
||||
volumes:
|
||||
- "./src/:/app:ro"
|
||||
env_file: backend.env
|
@ -16,7 +16,14 @@ db_params = {
|
||||
'port': int(env.get('DB_PORT'))
|
||||
}
|
||||
|
||||
db = psql.connect(**db_params)
|
||||
db = None
|
||||
|
||||
for _ in range(5):
|
||||
try:
|
||||
db = psql.connect(**db_params)
|
||||
except Exception as e:
|
||||
print(f"Failed to connect ({e}), retrying...")
|
||||
time.sleep(5)
|
||||
|
||||
class PassQueue:
|
||||
def __init__(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user