Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task/WG-134 setup docker compose for geoapi services vm #142

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
327a173
Add initial/work-in-progress docker-compose
nathanfranklin Sep 14, 2023
24fac06
Add nginx conf
nathanfranklin Sep 14, 2023
6910758
Move docker infrastructure to devops folder
nathanfranklin Sep 14, 2023
443c96a
Move remaining docker infrastructure to devops folder
nathanfranklin Sep 14, 2023
b15b0fc
Fix local development's docker-compose
nathanfranklin Sep 14, 2023
49774e1
Add additional improvements to docker-compose for geoapi-services vms
nathanfranklin Sep 14, 2023
466400e
Add some variables
nathanfranklin Sep 18, 2023
37486df
Use one env variable for mapillary
nathanfranklin Sep 19, 2023
ee47a45
Fix dockerfiles
nathanfranklin Sep 20, 2023
aa112f8
Add secret.env to gitignore
nathanfranklin Sep 20, 2023
33b6799
Update docker-compose test yaml
nathanfranklin Sep 20, 2023
4b5a557
Fix installing of python packages on github actions workflow
nathanfranklin Sep 20, 2023
d3ff8b3
Change to devops/ before running test on CI workflow
nathanfranklin Sep 20, 2023
cf069c6
Simplify install/pytest step in CI workflow
nathanfranklin Sep 20, 2023
d397f14
Refactor location of dockerfiles and images used
nathanfranklin Sep 21, 2023
f6ba45e
Fix nginx conf for deployment
nathanfranklin Sep 21, 2023
aca6a94
Change secrets location to /opt/portal/conf/secret.env
nathanfranklin Sep 22, 2023
0d05626
Use absolute path for secrets.env
nathanfranklin Sep 22, 2023
00669c4
Add makefile for geoapi-services
nathanfranklin Sep 22, 2023
e8d3447
Refactor dockerfile
nathanfranklin Sep 22, 2023
16e34d7
Correct path to poetry.lock and pyproject.toml
nathanfranklin Sep 22, 2023
10ccc52
Fix paths in dockerfile
nathanfranklin Sep 22, 2023
107b950
Rename Dockerfile.potree to Dockerfile.worker
nathanfranklin Sep 22, 2023
0ba35b9
Rename Dockerfile.potree to Dockerfile.worker again
nathanfranklin Sep 22, 2023
7289734
Fix workflow
nathanfranklin Sep 26, 2023
2457296
Fix workflow
nathanfranklin Sep 26, 2023
e0aebdc
Remove env file usage in Makefile
nathanfranklin Sep 26, 2023
a77c811
Pass in GEOAPI_TAG from env
nathanfranklin Sep 26, 2023
dbaa93a
Remove echo
nathanfranklin Sep 26, 2023
8549c82
Fix docker compose statement
nathanfranklin Sep 26, 2023
a7b41de
update docker compose and Makefile
nathanfranklin Sep 26, 2023
9445199
Fix MAKEFILE
nathanfranklin Sep 26, 2023
e30f69d
Add todo
nathanfranklin Sep 26, 2023
d041516
Fix MAKEFILE again
nathanfranklin Sep 26, 2023
7424b82
Add missing RABBITMQ_VHOST
nathanfranklin Sep 26, 2023
fb422f7
Do not run docker up in background for testing
nathanfranklin Sep 26, 2023
69efa06
Fix gitignore and improve dockerignore
nathanfranklin Sep 28, 2023
68b2f28
Bump rabbitmq version
nathanfranklin Sep 28, 2023
3a0d55c
Update todo
nathanfranklin Sep 28, 2023
e86673a
Fix tabbitmq password variable on example secrets file
nathanfranklin Sep 28, 2023
2f094b8
Refactor how settings are set based on APP_ENV
nathanfranklin Sep 28, 2023
f05f5c3
Add hazmapper to docker-compose
nathanfranklin Sep 28, 2023
4ebf185
Fix makefile
nathanfranklin Sep 28, 2023
e536f4b
Expose rabbitmq port from geoapi-services
nathanfranklin Sep 28, 2023
7d02cc4
Improve make build command
nathanfranklin Sep 29, 2023
104a9f3
Improve deploy command
nathanfranklin Sep 29, 2023
11acf8e
Add a copy of poetry files
nathanfranklin Sep 29, 2023
60ad7a7
Fix unit test settings
nathanfranklin Sep 29, 2023
530b614
Move to devops before running test
nathanfranklin Sep 29, 2023
565b012
Removed unused steps in workflow
nathanfranklin Sep 29, 2023
dff7254
Merge branch 'master' into task/WG-134-setup-docker-compose-for-geoap…
nathanfranklin Sep 29, 2023
5785a36
Merge branch 'task/WG-134-setup-docker-compose-for-geoapi-services-vm…
nathanfranklin Sep 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
**.pyc
.git
**/__pycache__

# Secret env file
.env
*secrets.env
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ jobs:
restore-keys: |
${{ runner.os }}-poetry-
- name: Install Python Packages
run: poetry install
run: |
cd devops
poetry install
- name: Run server-side unit tests
run: poetry run pytest
run: |
cd devops
poetry run pytest ../geoapi
Workers_Unit_Tests:
runs-on: ubuntu-latest
services:
Expand All @@ -86,7 +90,7 @@ jobs:
- name: Build worker image
run: |
docker pull taccaci/geoapi-workers:latest
docker build --cache-from taccaci/geoapi-workers:latest -t taccaci/geoapi-workers:latest -f Dockerfile.potree .
docker build --cache-from taccaci/geoapi-workers:latest -t taccaci/geoapi-workers:latest -f devops/Dockerfile.worker .
- name: Run worker test
run: |
docker run --network="host" -e APP_ENV='testing' -e DB_HOST='localhost' taccaci/geoapi-workers:latest pytest -m "worker"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__/

# Secret env file
.env
*secrets.env

# C extensions
*.so
Expand Down
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,34 @@ TAG := $(shell git log --format=%h -1)
GEOAPI_IMAGE=taccaci/geoapi
GEOAPI_WORKERS=taccaci/geoapi-workers

.PHONY: start
start:
docker-compose -f devops/docker-compose.local.yml --env-file .env up

.PHONY: stop
stop:
docker-compose -f devops/docker-compose.local.yml --env-file .env down

.PHONY: build
build:
make geoapi && make workers

.PHONY: geoapi
geoapi:
docker build -t $(GEOAPI_IMAGE):$(TAG) .
docker build -t $(GEOAPI_IMAGE):$(TAG) -f devops/Dockerfile .
docker tag $(GEOAPI_IMAGE):$(TAG) $(GEOAPI_IMAGE):latest
docker tag $(GEOAPI_IMAGE):$(TAG) $(GEOAPI_IMAGE):local

.PHONY: workers
workers:
docker build -t $(GEOAPI_WORKERS):$(TAG) -f Dockerfile.potree .
docker build -t $(GEOAPI_WORKERS):$(TAG) -f devops/Dockerfile.worker .
docker tag $(GEOAPI_WORKERS):$(TAG) $(GEOAPI_WORKERS):latest
docker tag $(GEOAPI_WORKERS):$(TAG) $(GEOAPI_WORKERS):local


.PHONY: deploy
deploy:
make deploy-geoapi && make deploy-workers

.PHONY: deploy-geoapi
deploy-geoapi:
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ information. An .env file for developers can be found on [UT Stache](https://sta
The API is built with flask and flask-restplus. It is running in its own container
under gunicorn on port 8000

`docker-compose up`
`make build`
`make start`

###### Initialize the database

Expand Down Expand Up @@ -87,17 +88,17 @@ alembic revision --autogenerate

Run route/service tests on the `api` container
```
docker-compose -f docker-compose.test.yml -p geoapi_test run api pytest
docker-compose -f devops/docker-compose.test.yml -p geoapi_test run api pytest
```

Run worker-related tasks on the `workers` container
```
docker-compose -f docker-compose.test.yml -p geoapi_test run workers pytest -m "worker"
docker-compose -f devops/docker-compose.test.yml -p geoapi_test run workers pytest -m "worker"
```

Note that images need to be rebuilt before running tests if they have been updated (e.g. packages):
```
docker-compose -f docker-compose.test.yml build
make build
```
## Kubernetes (Production/Staging)

Expand Down
18 changes: 0 additions & 18 deletions conf/nginx.kube.conf

This file was deleted.

9 changes: 6 additions & 3 deletions Dockerfile → devops/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ ENV POETRY_HOME=/opt/poetry
ENV PATH="$POETRY_HOME/bin:$PATH"
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN poetry config virtualenvs.create false
COPY pyproject.toml poetry.lock ./
RUN poetry install

RUN mkdir /app
COPY ./geoapi /app/geoapi
WORKDIR /app

COPY devops/poetry.lock devops/pyproject.toml ./
RUN poetry install

COPY geoapi /app/geoapi
ENV PYTHONPATH "${PYTHONPATH}:/app"
WORKDIR /app/geoapi
9 changes: 5 additions & 4 deletions Dockerfile.potree → devops/Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN git clone -b develop https://github.com/potree/PotreeConverter.git && cd Pot
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DLASZIP_INCLUDE_DIRS=/opt/LAStools/LASzip/dll/ -DLASZIP_LIBRARY=/usr/local/lib/liblaszip.so .. && \
make && make install && cp -r /opt/PotreeConverter/PotreeConverter/resources /resources
ADD misc/potree/page_template /resources/page_template
ADD devops/misc/potree/page_template /resources/page_template

RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2

Expand All @@ -32,16 +32,17 @@ ENV POETRY_HOME=/opt/poetry
ENV PATH="$POETRY_HOME/bin:$PATH"
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN poetry config virtualenvs.create false
COPY pyproject.toml poetry.lock ./
COPY devops/pyproject.toml devops/poetry.lock ./

RUN poetry install

ENV PYTHONPATH "${PYTHONPATH}:/app"

# isntall geos into condo the base pdal image is using
# install geos into condo the base pdal image is using
RUN conda install geos -y -n base


WORKDIR /
RUN mkdir app
COPY ./geoapi /app/geoapi
COPY geoapi /app/geoapi
WORKDIR /app/geoapi
30 changes: 12 additions & 18 deletions docker-compose.yml → devops/docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ networks:
services:

rabbitmq:
image: rabbitmq
image: rabbitmq:3.12.6
networks:
- geoapi
environment:
Expand All @@ -38,40 +38,36 @@ services:
- 8888:80
volumes:
- assets:/assets
- ./conf/nginx.conf:/etc/nginx/nginx.conf
- ./local_conf/nginx.conf:/etc/nginx/nginx.conf
networks:
- geoapi


workers:
build:
context: .
dockerfile: ./Dockerfile.potree
image: taccaci/geoapi-workers:local
networks:
- geoapi
volumes:
- .:/app
- ../:/app
- assets:/assets
environment:
- MAPILLARY_CLIENT_TOKEN=4866220476802272
- MAPILLARY_CLIENT_TOKEN=${MAPILLARY_CLIENT_TOKEN}
- FLASK_APP=/app/geoapi/app.py
- APP_ENV=development
- ASSETS_BASE_DIR=/assets
- TENANT
- TENANT=${TENANT}
stdin_open: true
tty: true
container_name: geoapiworkers
hostname: geoapiworkers
command: "celery -A geoapi.celery_app worker -l info"

celerybeat:
build:
context: .
dockerfile: ./Dockerfile.potree
image: taccaci/geoapi-workers:local
networks:
- geoapi
volumes:
- .:/app
- ../:/app
- assets:/assets
environment:
- MAPILLARY_CLIENT_TOKEN=4866220476802272
Expand All @@ -85,25 +81,23 @@ services:
command: "celery -A geoapi.celery_app beat -l info"

api:
build:
context: .
dockerfile: ./Dockerfile
image: taccaci/geoapi:local
networks:
- geoapi
volumes:
- .:/app
- ../:/app
- assets:/assets
ports:
- 8000:8000
dns:
- 8.8.8.8
- 8.8.4.4
environment:
- MAPILLARY_CLIENT_TOKEN=4866220476802272
- MAPILLARY_CLIENT_TOKEN=${MAPILLARY_CLIENT_TOKEN}
- FLASK_APP=/app/geoapi/app.py
- APP_ENV=development
- ASSETS_BASE_DIR=/assets
- TENANT
- TENANT=${TENANT}
stdin_open: true
tty: true
container_name: geoapi
Expand Down
20 changes: 6 additions & 14 deletions docker-compose.test.yml → devops/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ volumes:
networks:
geoapi:
driver: bridge
services:

services:
postgres_test:
image: mdillon/postgis:11-alpine
image: mdillon/postgis
volumes:
- pgdata:/var/lib/postgresql/data
ports:
Expand All @@ -28,13 +28,9 @@ services:
- POSTGRES_DB=test

workers:
build:
context: .
dockerfile: ./Dockerfile.potree
cache_from:
- taccaci/geoapi-workers:latest
image: taccaci/geoapi-workers:local
volumes:
- .:/app
- ..:/app
- assets:/assets
environment:
- MAPILLARY_CLIENT_TOKEN=4866220476802272
Expand All @@ -52,13 +48,9 @@ services:
hostname: geoapiworkers

api:
build:
context: .
dockerfile: ./Dockerfile
cache_from:
- taccaci/geoapi:latest
image: taccaci/geoapi-workers:local
volumes:
- .:/app
- ..:/app
- assets:/assets
ports:
- 8000:8000
Expand Down
13 changes: 13 additions & 0 deletions devops/geoapi-services/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

.PHONY: start
start:
echo "starting (GEOAPI_TAG=${GEOAPI_TAG})"
docker compose -f docker-compose.yml up -d

.PHONY: stop
stop:
docker compose -f docker-compose.yml down

.PHONY: pull
pull:
docker compose pull api workers nginx rabbitmq
Loading