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

Docker image continuous delivery #27

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
45 changes: 45 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Build and publish container image"

on:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "[0-9]+.[0-9]+.[0-9]+*"


env:
REGISTRY: "ghcr.io"
IMAGE_NAME: "${{ github.repository_owner }}/pdg3dtiles" # TODO: Is this the image name we want?
IMAGE_TAG: "${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}"


jobs:

build-and-release-image:
name: "Build and release container image"
runs-on: "ubuntu-latest"

permissions:
packages: "write"
attestations: "write"

steps:
- name: "Check out repository"
uses: "actions/checkout@v3"

- name: "Build container image"
run: |
docker build --tag "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}" .

- name: "GHCR login"
uses: "docker/login-action@v2"
with:
registry: "${{ env.REGISTRY }}"
username: "${{ github.repository_owner }}"
password: "${{ secrets.GITHUB_TOKEN }}"

- name: "Push to GHCR"
run: |
docker push "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.9-slim

# Install transitive dependencies
RUN apt-get update \
&& apt-get install -y \
git \
libgl1 \
libgomp1

# Install from source
WORKDIR /app
ADD . .
RUN pip install .


CMD ["python3"]
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This package was developed for the [Permafrost Discovery Gateway](https://permaf
### Conda

```bash
conda env create -n viz_3d --file environment.yml
conda env create
conda activate viz_3d
```

Expand All @@ -28,24 +28,39 @@ source .3dtilesenv/bin/activate
pip install -r requirements.txt
```

## Usage
### Other pre-requesites

`libgomp` and `libgl` are required on your system.

```bash
sudo apt install libgomp1 libgl1
# OR
conda install libgomp
```

1. Create an instance of the `Cesium3DTile` class. Use `Cesium3DTile.from_file()` to process a `.shp` file into a `.b3dm` 3D model:
> ![NOTE]
> `libgomp` can be expressed in `environment.yml`. Do that then combine this section
> with the pip install section?

## Usage

```python
from viz_3dtiles import Cesium3DTile, Cesium3DTileset

# 1. Create an instance of the `Cesium3DTile` class. Use `Cesium3DTile.from_file()` to
# process a `.gpkg` file into a `.b3dm` 3D model:
tile = Cesium3DTile()
tile.save_to="~/my-tilesets/lakes/"
tile.from_file(filepath="~/my-data/lakes.shp")
```
tile.from_file(filepath="~/my-data/lakes.gpkg")

2. Create an instance of the `Cesium3DTileset` class to contain that tile:
# 2. Create an instance of the `Cesium3DTileset` class to contain that tile:

```python
tileset = Cesium3DTileset(tiles=[tile])
tileset.save_to="~/my-tilesets/lakes/"
tileset.write_file()
```


## Demo

See [/test/test.py](test/test.py) which creates an example tileset.
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# usage: conda env create -n viz_3d --file environment.yml
# name: viz_3d
# usage: conda env create
name: viz_3d
channels:
- conda-forge
dependencies:
Expand Down
4 changes: 2 additions & 2 deletions viz_3dtiles/Cesium3DTile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def set_b3dm_name(self, name):

def get_all_properties(self):
"""
Get all proerties of the Cesium3DTile class as a dictionary.
Get all properties of the Cesium3DTile class as a dictionary.
"""
return {
"z": self.z,
Expand Down Expand Up @@ -238,4 +238,4 @@ def create_b3dm(self):
t.save_as(os.path.join(self.save_to, self.get_filename()))

def get_filename(self):
return self.save_as + self.FILE_EXT
return self.save_as + self.FILE_EXT