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

refactor Makefile and Dockerfile, and update README with better dev instructions #391

Conversation

philvarner
Copy link
Collaborator

@philvarner philvarner commented Mar 26, 2022

If these changes are acceptable, we also need to figure out what should be in the Readme vs. Contributing vs. the published docs, and what should be in the root readme vs. the pgstac readme

Related Issue(s):

Description:

  • refactor makefile targets to be more clear and work better for dev
  • rework multi-stage Dockerfile build to run faster and remove unused directives
  • update README with better instructions for running

PR Checklist:

  • Code is formatted and linted (run pre-commit run --all-files)
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the CHANGELOG.

* rework multi-stage Dockerfile build to run faster and remove unused
  directives
* update README with better instructions for running
Dockerfile Outdated
# Any python libraries that require system libraries to be installed will likely
# need the following packages in order to build
RUN apt-get update && apt-get install -y build-essential git
RUN apt-get update && \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be in the base stage, since it doesn't need to be re-executed each time and can be cached

Dockerfile Outdated

ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

ARG install_dev_dependencies=true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't do anything AFAIK

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this was used before we switched away from pipenv.

Dockerfile Outdated
COPY . /app

ENV PATH=$PATH:/install/bin
Copy link
Collaborator Author

@philvarner philvarner Mar 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/install doesn't seem to be used for anything? it gets added to the path and created, but nothing is ever done with it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used as a directory to hold the outputs of pip install -e but I don't think its needed. The upside is it makes the WORKDIR a little cleaner, downside is it makes the Dockerfile a little more complex. Personally I'm fine removing it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain to me how it's configured to be used as a directory to hold the pipe install -e outputs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think I actually just stumbled upon the example where this dockerfile came from: https://blog.realkinetic.com/building-minimal-docker-containers-for-python-applications-37d0272c52f3

What's missing is that pip isn't being invoked with --install-option="--prefix=/install", so it's not actually being used. (I thought this might be the case, but there's a lot of implicit python magic I don't know about yet)

Makefile Outdated
.PHONY: docker-run
docker-run: image
$(run_docker)
.PHONY: docker-run-all
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this so all the commands can be done with make rather than docker-compose.

Makefile Outdated
docker-run-all:
docker-compose up

.PHONY: docker-run-sqlalchemy
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explicitly renamed all the targets like docker-run to docker-run-sqlalchemy, since that's what it does.

Makefile Outdated

.PHONY: test-pgstac
test-pgstac:
$(run_pgstac) /bin/bash -c 'export && ./scripts/wait-for-it.sh database:5432 && cd /app/stac_fastapi/pgstac/tests/ && pytest -vvv --asyncio-mode=auto'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's another PR where this gets added to pytest.ini, merge that PR first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, went ahead and reverted it.

@@ -47,35 +46,16 @@ pip install -e \
stac_fastapi/pgstac[dev,server]
```

## Local Development
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated from root Readme now.

Dockerfile Outdated
COPY . /app

ENV PATH=$PATH:/install/bin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used as a directory to hold the outputs of pip install -e but I don't think its needed. The upside is it makes the WORKDIR a little cleaner, downside is it makes the Dockerfile a little more complex. Personally I'm fine removing it.

@moradology moradology merged commit 93c4b1a into stac-utils:master Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants