Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Virtual environments
.direnv
venv/
28 changes: 28 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and push digital-land-python to public ECR
on:
push:
branches:
# - main # TODO reinstate this before merge
- run-pipeline-commands-locally

jobs:
build:

runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
python-version: 3.8
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Build & Push
run: |
make docker-build
make docker-push

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var/cache
ssl.pem
var
.junitxml
.envrc
pyrightconfig.json
.idea
.python-version
.python-version
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM python:3.8 as digital-land-python

RUN set -xe && \
apt-get update && \
apt-get install -y \
awscli \
time \
gosu \
make \
git \
gdal-bin \
libspatialite-dev \
libsqlite3-mod-spatialite

WORKDIR /src
COPY . /src

# Necessary to make sure the `digital-land` easyinstall entry script is found when invoking
# `digital-land` via shell from python space
ENV VIRTUAL_ENV=/opt/venv
RUN pip install --upgrade pip
RUN pip install virtualenv
RUN cd /opt && virtualenv venv --always-copy
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN make init

FROM digital-land-python as digital-land-specification

RUN mkdir -p /collection
WORKDIR /collection
RUN set -ex; \
wget https://github.com/digital-land/makerules/archive/refs/heads/run-all-pipeline-commands-locally-take-2.zip -O makerules.zip; \
unzip makerules.zip; \
make specification -f makerules-run-all-pipeline-commands-locally-take-2/makerules.mk
# TODO switch branch when merged
# wget https://github.com/digital-land/makerules/archive/refs/heads/main.zip -O makerules.zip; \
# make specification -f makerules-main/makerules.mk

FROM digital-land-specification as digital-land-pipeline

WORKDIR /pipeline
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ Development requires Python 3.6.2 or later, we recommend using a [virtual enviro
make
python -m digital-land --help

There is also a docker image available on public ECR

```
docker run -it public.ecr.aws/l6z6v3j6/digital-land-python:latest digital-land
```

## Release procedure

Update the tagged version number:
Expand Down
25 changes: 25 additions & 0 deletions makerules/python.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
PIP_INSTALL_PACKAGE=[test]
ECR_REPO=public.ecr.aws/l6z6v3j6/

LAYER_NAME=digital-land-python
REPO_NAME=digital-land-python
ECR_PATH=$(ECR_REPO)$(REPO_NAME):$(LAYER_NAME)

all:: lint test coverage

Expand Down Expand Up @@ -45,3 +50,23 @@ upload:: dist

makerules::
curl -qfsL '$(SOURCE_URL)/makerules/main/python.mk' > makerules/python.mk

docker-build: docker-check
docker build . -t $(ECR_PATH) --target $(LAYER_NAME)

docker-push: docker-check docker-ecr-login
docker push $(ECR_PATH)

docker-pull: docker-check docker-ecr-login
docker pull $(ECR_PATH)

docker-shell: docker-check docker-ecr-login
docker run -it $(ECR_PATH) bash

docker-check:
ifeq (, $(shell which docker))
$(error "No docker in $(PATH), consider doing apt-get install docker OR brew install --cask docker")
endif

docker-ecr-login:
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws