-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from GISdevio/final-refactoring
Refactoring and Dockerization
- Loading branch information
Showing
166 changed files
with
489 additions
and
496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: [ 'main' ] | ||
pull_request: | ||
branches: [ 'main' ] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- context: backend | ||
suffix: -backend | ||
- context: webapp | ||
suffix: -webapp | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- | ||
name: Login to registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ matrix.suffix }} | ||
- | ||
name: Build and push container | ||
uses: docker/build-push-action@v5 | ||
with: | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
context: ${{ matrix.context }} | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,47 @@ | ||
# Setup on Debian 11 | ||
# Setup | ||
|
||
Everything is run inside `/srv`, if not specified otherwise. | ||
Prerequisites: | ||
- docker | ||
- docker compose | ||
- git | ||
|
||
## Install dependencies | ||
|
||
### Common | ||
|
||
```bash | ||
apt-get install \ | ||
`# generic` | ||
git sqlite3 libsqlite3-mod-spatialite | ||
`# web app` | ||
npm \ | ||
nginx libnginx-mod-http-lua \ | ||
`# pbf` \ | ||
osmium-tool \ | ||
`# OsmAndMapCreator` \ | ||
openjdk-11-jre-headless \ | ||
`# gpkg` \ | ||
gdal-bin | ||
``` | ||
|
||
### Clone repository | ||
## Clone repository | ||
|
||
```bash | ||
git clone https://github.com/osmItalia/estratti_OSM_Italia.git | ||
cd estratti_OSM_Italia | ||
``` | ||
|
||
## Configuration | ||
|
||
### Scripts | ||
|
||
#### Prepare environment | ||
|
||
```bash | ||
source estratti_osm-it.env | ||
``` | ||
|
||
#### Setup OsmAndMapCreator | ||
## Run using Docker | ||
|
||
```bash | ||
mkdir -p "$OSMAND_DIR" | ||
cd "$_" | ||
wget https://download.osmand.net/latest-night-build/OsmAndMapCreator-main.zip | ||
unzip OsmAndMapCreator-main | ||
rm OsmAndMapCreator-main.zip | ||
docker compose up --build | ||
``` | ||
|
||
#### mapshaper and topojson | ||
## Run without Docker | ||
|
||
Additional setup that could be required on WM servers to run npm: | ||
### Backend | ||
|
||
```bash | ||
sudo aptitude install npm # select second option | ||
``` | ||
|
||
Install mapshaper and topojson: | ||
It is suggested to use `nix` or `nix-portable` to create an environment with the dependencies installed | ||
|
||
```bash | ||
npm --prefix=$NPM_PREFIX install mapshaper | ||
npm --prefix=$NPM_PREFIX install topojson-server | ||
cd backend/ | ||
nix-shell --pure | ||
make setup | ||
make pbf | ||
make -j$(nproc) | ||
make webapp | ||
``` | ||
|
||
#### Run | ||
|
||
```bash | ||
./run.sh | ||
``` | ||
### Frontend | ||
|
||
### Web | ||
|
||
Modify `default` accordingly to your needs. | ||
Configure NGINX by customizing `nginx/default.conf`. Adjust `src/configuration.json` if needed (read more at `frontend/README.md`). | ||
|
||
```bash | ||
cp nginx/default.conf /etc/nginx/sites-enabled/default | ||
systemctl start nginx | ||
systemctl enable nginx | ||
|
||
cd webapp | ||
cd frontend/ | ||
npm install | ||
npm run build | ||
``` | ||
|
||
### crontab (example) | ||
|
||
``` | ||
0 2 * * * /srv/estratti_OSM_Italia/backend/run.sh | ||
``` | ||
The contents of `build/` should be served by NGINX. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM docker.io/library/debian:trixie | ||
|
||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | ||
--mount=type=cache,sharing=locked,target=/var/lib/apt \ | ||
rm /etc/apt/apt.conf.d/docker-clean && \ | ||
apt-get update && \ | ||
apt-get install -yq --no-install-recommends \ | ||
`# generic` \ | ||
curl gettext make anacron sqlite3 libsqlite3-mod-spatialite \ | ||
`# pbf` \ | ||
osmium-tool \ | ||
`# OsmAndMapCreator` \ | ||
libarchive-tools openjdk-17-jre-headless \ | ||
`# boundaries, gpkg` \ | ||
gdal-bin \ | ||
`# mapshaper, topojson` \ | ||
npm \ | ||
&& \ | ||
rm /etc/cron.daily/apt-compat /etc/cron.daily/dpkg | ||
|
||
WORKDIR /root | ||
# https://github.com/moby/moby/issues/17175 | ||
COPY Makefile . | ||
RUN make setup | ||
|
||
COPY scripts/ scripts/ | ||
COPY cronjob.sh /etc/cron.daily/estratti | ||
|
||
CMD ["anacron", "-d"] |
Oops, something went wrong.