Skip to content

Commit

Permalink
Upgrade circleci machine version and cleaning build files (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaesivsm authored Mar 5, 2022
1 parent 6349b5c commit 96c9683
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 45 deletions.
56 changes: 23 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ orbs:
jobs:
backend-build:
machine:
image: ubuntu-2004:202111-01
image: ubuntu-2004:202201-02
steps:
- checkout
# restore cache and docker layer cache
Expand All @@ -22,10 +22,11 @@ jobs:
set +o pipefail
docker load -i ~/caches/jarr-server.tar | true
docker load -i ~/caches/jarr-worker.tar | true
mkdir -p ~/caches
- run:
name: Building images for server and worker
name: Building docker backend images
command: |
mkdir -p ~/caches
make build-base
make build-server
make build-worker
- run:
Expand All @@ -41,7 +42,7 @@ jobs:

front-build:
machine:
image: ubuntu-2004:202111-01
image: ubuntu-2004:202201-02
steps:
- checkout
# restore cache and docker layer cache
Expand Down Expand Up @@ -71,7 +72,7 @@ jobs:

backend-test:
machine:
image: ubuntu-2004:202111-01
image: ubuntu-2004:202201-02
steps:
- checkout
# restore cache and docker layer cache
Expand All @@ -93,38 +94,33 @@ jobs:
rm example_conf/jarr.test.json example_conf/jarr.json
mv example_conf/jarr.circleci.json example_conf/jarr.json
- run:
name: Starting test env (postgres)
name: Starting test environment
command: |
docker-compose --file Dockerfiles/circleci-env.yml up -d
sleep 10s
- run:
name: Creating postgres database
command: >-
docker-compose --file Dockerfiles/circleci-env.yml
exec postgresql su postgres -c
"createdb jarr --no-password"
make start-env RUN= COMPOSE_FILE=Dockerfiles/circleci-env.yml
sleep 2
make db-bootstrap-user RUN= COMPOSE_FILE=Dockerfiles/circleci-env.yml
make db-bootstrap-tables RUN= COMPOSE_FILE=Dockerfiles/circleci-env.yml
- run:
name: Populating database with tables
name: Bootstraping database
command: >-
docker-compose --file Dockerfiles/circleci-env.yml
exec server bash -c "pipenv run flask bootstrap-database"
docker-compose --file Dockerfiles/circleci-env.yml --project-name=jarr
exec server bash -c "make init-env"
- run:
name: Installing testing dependencies
command: >-
docker-compose --file Dockerfiles/circleci-env.yml
exec server bash -c "pipenv sync --dev --bare"
docker-compose --file Dockerfiles/circleci-env.yml --project-name=jarr
exec server bash -c "make install"
- run:
name: Running tests
command: >-
docker-compose --file Dockerfiles/circleci-env.yml
exec server bash -c
"pipenv run nosetests tests/ -vv --with-coverage --cover-package=jarr"
docker-compose --file Dockerfiles/circleci-env.yml --project-name=jarr
exec server bash -c "make test JARR_CONFIG=example_conf/jarr.json"
- run:
name: Uplaoding coverage to codacy
command: >-
docker-compose --file Dockerfiles/circleci-env.yml
docker-compose --file Dockerfiles/circleci-env.yml --project-name=jarr
exec -u root server bash -c "chown -R jarr:jarr /jarr/coverage_results";
docker-compose --file Dockerfiles/circleci-env.yml
docker-compose --file Dockerfiles/circleci-env.yml --project-name=jarr
exec server bash -c
"pipenv run coverage xml -o coverage_results/coverage.xml";
pip install --upgrade codacy-coverage;
Expand All @@ -133,18 +129,12 @@ jobs:
name: Running PEP8 linter
command: >-
docker-compose --file Dockerfiles/circleci-env.yml
exec server bash -c
"pipenv run pycodestyle --ignore=E126,E127,E128,W503 jarr/ --exclude=jarr/migrations"
- run:
name: Running MyPy linter
command: >-
docker-compose --file Dockerfiles/circleci-env.yml
exec server bash -c
"pip install types-redis types-requests types-python-dateutil; pipenv run mypy jarr --ignore-missing-imports --exclude=jarr/crawler/lib/__init__.py"
--project-name=jarr
exec server bash -c "make lint"
push-docker-images:
machine:
image: ubuntu-1604:201903-01
image: ubuntu-2004:202201-02
environment:
GIT_TAG: << pipeline.git.tag >>
steps:
Expand Down
7 changes: 6 additions & 1 deletion Dockerfiles/circleci-env.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
version: '3.2'
services:
postgresql:
postgres:
hostname: postgres
image: postgres:13
ports:
- 0.0.0.0:5432:5432
environment:
- POSTGRES_PASSWORD=password
redis:
hostname: redis
image: redis
ports:
- 0.0.0.0:6379:6379
server:
hostname: server
container_name: server
image: jarr-server:latest
volumes:
- "/home/circleci/project/Makefile:/jarr/Makefile"
- "/home/circleci/project/tests:/jarr/tests"
- "/home/circleci/project/example_conf:/etc/jarr"
- "/home/circleci/coverage_results:/jarr/coverage_results:rw"
2 changes: 1 addition & 1 deletion Dockerfiles/dev-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- 0.0.0.0:4369:4369
- 0.0.0.0:5671:5671
- 0.0.0.0:5672:5672
postgresql:
postgres:
image: postgres:13
environment:
- POSTGRES_PASSWORD=password
Expand Down
6 changes: 3 additions & 3 deletions Dockerfiles/prod-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
volumes:
- ../example_conf/:/etc/jarr:ro
depends_on:
- postgresql
- postgres
- redis
- rabbitmq
networks:
Expand All @@ -31,7 +31,7 @@ services:
volumes:
- ../example_conf/:/etc/jarr:ro
depends_on:
- postgresql
- postgres
- redis
- rabbitmq
networks:
Expand All @@ -44,7 +44,7 @@ services:
image: redis
networks:
- jarr
postgresql:
postgres:
image: postgres:13
networks:
- jarr
Expand Down
6 changes: 3 additions & 3 deletions Dockerfiles/pythonbase
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM python:3.9-slim

RUN useradd jarr --create-home --shell /bin/bash --home-dir /jarr --user-group
COPY example_conf/jarr.json /etc/jarr/jarr.json
WORKDIR /jarr
RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
gcc \
Expand All @@ -10,9 +13,6 @@ RUN apt-get update \
&& apt clean --yes \
&& apt autoremove --yes \
&& rm -rf /var/log/apt /var/cache/apt /var/log/apt
RUN useradd jarr --create-home --shell /bin/bash --home-dir /jarr --user-group
COPY example_conf/jarr.json /etc/jarr/jarr.json
WORKDIR /jarr
USER jarr
COPY ./Pipfil* /jarr/
RUN mkdir /tmp/pipenv \
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DB_NAME ?= jarr
PUBLIC_URL ?=
REACT_APP_API_URL ?=
QUEUE ?= jarr,jarr-crawling,jarr-clustering
DB_CONTAINER_NAME = postgresql
DB_CONTAINER_NAME = postgres
QU_CONTAINER_NAME = rabbitmq

install:
Expand All @@ -35,12 +35,12 @@ build-base:
--file Dockerfiles/pythonbase \
-t jarr-base

build-server: build-base
build-server:
docker build --cache-from=jarr . \
--file Dockerfiles/server \
-t jarr-server

build-worker: build-base
build-worker:
docker build --cache-from=jarr . \
--file Dockerfiles/worker \
-t jarr-worker
Expand Down
2 changes: 1 addition & 1 deletion example_conf/jarr.circleci.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"level": 0
},
"db": {
"pg_uri": "postgresql://postgres:password@postgresql:5432/jarr",
"pg_uri": "postgresql://postgres:password@postgres:5432/jarr",
"redis": {"host": "redis"}
},
"celery": {"broker": "amqp://0.0.0.0//",
Expand Down

0 comments on commit 96c9683

Please sign in to comment.