Skip to content

Commit 6ad8591

Browse files
author
Phil Varner
authored
Merge pull request #79 from stac-utils/pv/create-docker-image-for-deploy
Pv/create docker image for deploy
2 parents f10ffb0 + 3a4bb17 commit 6ad8591

File tree

14 files changed

+77
-124
lines changed

14 files changed

+77
-124
lines changed

Dockerfile

Lines changed: 0 additions & 22 deletions
This file was deleted.

Dockerfile.deploy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM python:3.8-slim
2+
3+
RUN apt-get update && \
4+
apt-get -y upgrade && \
5+
apt-get clean && \
6+
rm -rf /var/lib/apt/lists/*
7+
8+
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
9+
10+
WORKDIR /app
11+
12+
COPY . /app
13+
14+
RUN pip install --no-cache-dir ./stac_fastapi/elasticsearch[server]
15+
16+
EXPOSE 8080
17+
18+
CMD ["uvicorn", "stac_fastapi.elasticsearch.app:app", "--host", "0.0.0.0", "--port", "8080"]

Dockerfile.dev

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM python:3.8-slim
2+
3+
4+
# update apt pkgs, and install build-essential for ciso8601
5+
RUN apt-get update && \
6+
apt-get -y upgrade && \
7+
apt-get install -y build-essential && \
8+
apt-get clean && \
9+
rm -rf /var/lib/apt/lists/*
10+
11+
# update certs used by Requests
12+
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
13+
14+
WORKDIR /app
15+
16+
COPY . /app
17+
18+
RUN pip install --no-cache-dir -e ./stac_fastapi/elasticsearch[dev,server]

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,24 @@ run_es = docker-compose \
1313

1414
.PHONY: image
1515
image:
16+
docker build -f Dockerfile.deploy -t stac-fastapi-elasticsearch:latest .
17+
18+
.PHONY: run
19+
run:
20+
docker run -it -p 8080:8080 \
21+
-e ENVIRONMENT=local \
22+
-e ES_HOST=docker.for.mac.localhost \
23+
-e ES_PORT=9200 \
24+
-e ES_USER=dev \
25+
-e ES_PASS=stac \
26+
stac-fastapi-elasticsearch:latest
27+
28+
.PHONY: image-dev
29+
image-dev:
1630
docker-compose build
1731

1832
.PHONY: docker-run
19-
docker-run: image
33+
docker-run: image-dev
2034
$(run_es)
2135

2236
.PHONY: docker-shell

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pre-commit run --all-files`
3232
docker-compose build
3333
```
3434

35-
## Running API on localhost:8083
35+
## Running API on localhost:8080
3636

3737
```shell
3838
docker-compose up
@@ -50,7 +50,7 @@ TBD: how to run this with 8.x with a password enabled and TLS.
5050
To create a new Collection:
5151

5252
```shell
53-
curl -X "POST" "http://localhost:8083/collections" \
53+
curl -X "POST" "http://localhost:8080/collections" \
5454
-H 'Content-Type: application/json; charset=utf-8' \
5555
-d $'{
5656
"id": "my_collection"

data_loader/data_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import requests
77

88
DATA_DIR = os.path.join(os.path.dirname(__file__), "setup_data/")
9-
STAC_API_BASE_URL = "http://localhost:8083"
9+
STAC_API_BASE_URL = "http://localhost:8080"
1010

1111

1212
def load_data(filename):

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ services:
77
restart: always
88
build:
99
context: .
10-
dockerfile: Dockerfile
10+
dockerfile: Dockerfile.dev
1111
environment:
1212
- APP_HOST=0.0.0.0
13-
- APP_PORT=8083
13+
- APP_PORT=8080
1414
- RELOAD=false
1515
- ENVIRONMENT=local
1616
- WEB_CONCURRENCY=10
@@ -19,7 +19,7 @@ services:
1919
- ES_PORT=9200
2020
- ES_HOST=172.17.0.1
2121
ports:
22-
- "8083:8083"
22+
- "8080:8080"
2323
volumes:
2424
- ./stac_fastapi:/app/stac_fastapi
2525
- ./scripts:/app/scripts

postman_collections/stac-fastapi-elasticsearch.postman_collection.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"method": "GET",
1212
"header": [],
1313
"url": {
14-
"raw": "http://localhost:8083/",
14+
"raw": "http://localhost:8080/",
1515
"protocol": "http",
1616
"host": [
1717
"localhost"
@@ -30,7 +30,7 @@
3030
"method": "GET",
3131
"header": [],
3232
"url": {
33-
"raw": "http://localhost:8083/collections",
33+
"raw": "http://localhost:8080/collections",
3434
"protocol": "http",
3535
"host": [
3636
"localhost"
@@ -49,7 +49,7 @@
4949
"method": "DELETE",
5050
"header": [],
5151
"url": {
52-
"raw": "http://localhost:8083/collections/test-collection",
52+
"raw": "http://localhost:8080/collections/test-collection",
5353
"protocol": "http",
5454
"host": [
5555
"localhost"
@@ -69,7 +69,7 @@
6969
"method": "DELETE",
7070
"header": [],
7171
"url": {
72-
"raw": "http://localhost:8083/collections/test-collection/items/test-item",
72+
"raw": "http://localhost:8080/collections/test-collection/items/test-item",
7373
"protocol": "http",
7474
"host": [
7575
"localhost"
@@ -91,7 +91,7 @@
9191
"method": "GET",
9292
"header": [],
9393
"url": {
94-
"raw": "http://localhost:8083/collections/test-collection",
94+
"raw": "http://localhost:8080/collections/test-collection",
9595
"protocol": "http",
9696
"host": [
9797
"localhost"
@@ -111,7 +111,7 @@
111111
"method": "GET",
112112
"header": [],
113113
"url": {
114-
"raw": "http://localhost:8083/collections/test-collection/items",
114+
"raw": "http://localhost:8080/collections/test-collection/items",
115115
"protocol": "http",
116116
"host": [
117117
"localhost"
@@ -132,7 +132,7 @@
132132
"method": "GET",
133133
"header": [],
134134
"url": {
135-
"raw": "http://localhost:8083/collections/test-collection/items/test-item",
135+
"raw": "http://localhost:8080/collections/test-collection/items/test-item",
136136
"protocol": "http",
137137
"host": [
138138
"localhost"
@@ -169,7 +169,7 @@
169169
"raw": "{\n \"id\": \"test-collection\",\n \"stac_extensions\": [\"https://stac-extensions.github.io/eo/v1.0.0/schema.json\"],\n \"type\": \"Collection\",\n \"description\": \"Landat 8 imagery radiometrically calibrated and orthorectified using gound points and Digital Elevation Model (DEM) data to correct relief displacement.\",\n \"stac_version\": \"1.0.0\",\n \"summaries\": {\n \"platform\": [\"landsat-8\"],\n \"instruments\": [\"oli\", \"tirs\"],\n \"gsd\": [30]\n },\n \"extent\": {\n \"spatial\": {\n \"bbox\": [\n [\n -180.0,\n -90.0,\n 180.0,\n 90.0\n ]\n ]\n },\n \"temporal\": {\n \"interval\": [\n [\n \"2013-06-01\",\n null\n ]\n ]\n }\n },\n \"links\": [\n {\n \"href\": \"http://localhost:8081/collections/landsat-8-l1\",\n \"rel\": \"self\",\n \"type\": \"application/json\"\n },\n {\n \"href\": \"http://localhost:8081/\",\n \"rel\": \"parent\",\n \"type\": \"application/json\"\n },\n {\n \"href\": \"http://localhost:8081/collections/landsat-8-l1/items\",\n \"rel\": \"item\",\n \"type\": \"application/geo+json\"\n },\n {\n \"href\": \"http://localhost:8081/\",\n \"rel\": \"root\",\n \"type\": \"application/json\"\n }\n ],\n \"title\": \"Landsat 8 L1\",\n \"keywords\": [\n \"landsat\",\n \"earth observation\",\n \"usgs\"\n ]\n}"
170170
},
171171
"url": {
172-
"raw": "http://localhost:8083/collections",
172+
"raw": "http://localhost:8080/collections",
173173
"protocol": "http",
174174
"host": [
175175
"localhost"
@@ -203,7 +203,7 @@
203203
"raw": "{\n \"type\": \"Feature\",\n \"id\": \"test-item\",\n \"stac_version\": \"1.0.0\",\n \"stac_extensions\": [\n \"https://stac-extensions.github.io/eo/v1.0.0/schema.json\",\n \"https://stac-extensions.github.io/projection/v1.0.0/schema.json\"\n ],\n \"geometry\": {\n \"coordinates\": [\n [\n [\n 152.15052873427666,\n -33.82243006904891\n ],\n [\n 150.1000346138806,\n -34.257132625788756\n ],\n [\n 149.5776607193635,\n -32.514709769700254\n ],\n [\n 151.6262528041627,\n -32.08081674221862\n ],\n [\n 152.15052873427666,\n -33.82243006904891\n ]\n ]\n ],\n \"type\": \"Polygon\"\n },\n \"properties\": {\n \"datetime\": \"2018-02-12T12:30:22Z\",\n \"landsat:scene_id\": \"LC82081612020043LGN00\",\n \"landsat:row\": \"161\",\n \"gsd\": 15,\n \"landsat:revision\": \"00\",\n \"view:sun_azimuth\": -148.83296771,\n \"instrument\": \"OLI_TIRS\",\n \"landsat:product_id\": \"LC08_L1GT_208161_20200212_20200212_01_RT\",\n \"eo:cloud_cover\": 0,\n \"landsat:tier\": \"RT\",\n \"landsat:processing_level\": \"L1GT\",\n \"landsat:column\": \"208\",\n \"platform\": \"landsat-8\",\n \"proj:epsg\": 32756,\n \"view:sun_elevation\": -37.30791534,\n \"view:off_nadir\": 0,\n \"height\": 2500,\n \"width\": 2500\n },\n \"bbox\": [\n 149.57574,\n -34.25796,\n 152.15194,\n -32.07915\n ],\n \"collection\": \"test-collection\",\n \"assets\": {},\n \"links\": [\n {\n \"href\": \"http://localhost:8081/collections/landsat-8-l1/items/LC82081612020043\",\n \"rel\": \"self\",\n \"type\": \"application/geo+json\"\n },\n {\n \"href\": \"http://localhost:8081/collections/landsat-8-l1\",\n \"rel\": \"parent\",\n \"type\": \"application/json\"\n },\n {\n \"href\": \"http://localhost:8081/collections/landsat-8-l1\",\n \"rel\": \"collection\",\n \"type\": \"application/json\"\n },\n {\n \"href\": \"http://localhost:8081/\",\n \"rel\": \"root\",\n \"type\": \"application/json\"\n }\n ]\n}"
204204
},
205205
"url": {
206-
"raw": "http://localhost:8083/collections/test-collection/items",
206+
"raw": "http://localhost:8080/collections/test-collection/items",
207207
"protocol": "http",
208208
"host": [
209209
"localhost"
@@ -239,7 +239,7 @@
239239
"raw": "{\n \"collections\":[\"test-collection\"],\n \"intersects\":{\"type\": \"Point\", \"coordinates\": [150.04, -33.14]}\n}"
240240
},
241241
"url": {
242-
"raw": "http://localhost:8083/search",
242+
"raw": "http://localhost:8080/search",
243243
"protocol": "http",
244244
"host": [
245245
"localhost"
@@ -273,7 +273,7 @@
273273
"raw": "{\n \"collections\":[\"sentinel-s2-l2a\"],\n \"bbox\": [-69.433594,-10.660608,-47.285156,3.513421]\n}"
274274
},
275275
"url": {
276-
"raw": "http://localhost:8083/search",
276+
"raw": "http://localhost:8080/search",
277277
"protocol": "http",
278278
"host": [
279279
"localhost"
@@ -298,7 +298,7 @@
298298
}
299299
],
300300
"url": {
301-
"raw": "http://localhost:8083/search?query={\"gsd\": {\"gt\": 14}}",
301+
"raw": "http://localhost:8080/search?query={\"gsd\": {\"gt\": 14}}",
302302
"protocol": "http",
303303
"host": [
304304
"localhost"

stac_fastapi/elasticsearch/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"elasticsearch-dsl==7.4.0",
1919
"pystac[validation]",
2020
"uvicorn",
21+
"overrides",
2122
]
2223

2324
extra_reqs = {
@@ -28,7 +29,6 @@
2829
"pre-commit",
2930
"requests",
3031
"ciso8601",
31-
"overrides",
3232
"httpx",
3333
],
3434
"docs": ["mkdocs", "mkdocs-material", "pdocs"],

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
@app.on_event("startup")
4848
async def _startup_event():
49-
IndexesClient().create_indexes()
49+
await IndexesClient().create_indexes()
5050

5151

5252
def run():

stac_fastapi/elasticsearch/tests/api/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async def test_app_fields_extension(load_test_data, app_client, txn_client):
118118
resp_json = resp.json()
119119
assert list(resp_json["features"][0]["properties"]) == ["datetime"]
120120

121-
txn_client.delete_item(item["id"], item["collection"], request=MockRequest)
121+
txn_client.delete_item(item["id"], item["collection"])
122122

123123

124124
async def test_app_query_extension_gt(app_client, ctx):

stac_fastapi/elasticsearch/tests/clients/test_elasticsearch.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def test_create_collection(app_client, ctx, core_client, txn_client):
1717
await txn_client.create_collection(in_coll, request=MockRequest)
1818
got_coll = await core_client.get_collection(in_coll["id"], request=MockRequest)
1919
assert got_coll["id"] == in_coll["id"]
20-
await txn_client.delete_collection(in_coll["id"], request=MockRequest)
20+
await txn_client.delete_collection(in_coll["id"])
2121

2222

2323
async def test_create_collection_already_exists(app_client, ctx, txn_client):
@@ -29,7 +29,7 @@ async def test_create_collection_already_exists(app_client, ctx, txn_client):
2929
with pytest.raises(ConflictError):
3030
await txn_client.create_collection(data, request=MockRequest)
3131

32-
await txn_client.delete_collection(data["id"], request=MockRequest)
32+
await txn_client.delete_collection(data["id"])
3333

3434

3535
async def test_update_collection(
@@ -46,7 +46,7 @@ async def test_update_collection(
4646
coll = await core_client.get_collection(data["id"], request=MockRequest)
4747
assert "new keyword" in coll["keywords"]
4848

49-
await txn_client.delete_collection(data["id"], request=MockRequest)
49+
await txn_client.delete_collection(data["id"])
5050

5151

5252
async def test_delete_collection(
@@ -57,7 +57,7 @@ async def test_delete_collection(
5757
data = load_test_data("test_collection.json")
5858
await txn_client.create_collection(data, request=MockRequest)
5959

60-
await txn_client.delete_collection(data["id"], request=MockRequest)
60+
await txn_client.delete_collection(data["id"])
6161

6262
with pytest.raises(NotFoundError):
6363
await core_client.get_collection(data["id"], request=MockRequest)
@@ -73,7 +73,7 @@ async def test_get_collection(
7373
coll = await core_client.get_collection(data["id"], request=MockRequest)
7474
assert coll["id"] == data["id"]
7575

76-
await txn_client.delete_collection(data["id"], request=MockRequest)
76+
await txn_client.delete_collection(data["id"])
7777

7878

7979
async def test_get_item(app_client, ctx, core_client):

stac_fastapi/elasticsearch/tests/features/__init__.py

Whitespace-only changes.

stac_fastapi/elasticsearch/tests/features/test_custom_models.py

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)