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

fix: dockerfile #12

Merged
merged 1 commit into from
Dec 23, 2023
Merged
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
44 changes: 44 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Create and publish a Docker image

on:
push:
branches: ['master']
tags:
- 'v*'
pull_request:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
63 changes: 35 additions & 28 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI
name: Create and publish a Docker image

on:
push:
branches: [ master ]
paths:
- "data/**"
- "public/**"
branches: ['master']
tags:
- 'v*'

jobs:
build:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- run: npm run extract
- name: configure git and deploy
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
git config --global user.name "wasac+githubci"
git config --global user.email "wasac+githubci@users.noreply.github.com"
git remote set-url origin https://x-access-token:${NODE_AUTH_TOKEN}@github.com/WASAC/vt.git
npm run deploy

- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
public/tiles
.DS_Store

# Logs
logs
Expand Down
14 changes: 3 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Start from ubuntu
FROM ubuntu:16.04
FROM node:18

# Update repos and install dependencies
RUN apt-get update \
Expand All @@ -8,24 +8,16 @@ RUN apt-get update \
build-essential \
libsqlite3-dev \
zlib1g-dev \
curl \
wget \
git \
nodejs \
npm
git

# Build tippecanoe
RUN mkdir -p /tmp/src
WORKDIR /tmp/src
RUN git clone https://github.com/mapbox/tippecanoe.git
RUN git clone https://github.com/felt/tippecanoe.git
WORKDIR /tmp/src/tippecanoe
RUN make \
&& make install

# Install Nodejs
RUN npm cache clean && npm install n -g && n stable \
&& n 12.18.1 && ln -sf /usr/local/bin/node /usr/bin/node

# Install postgis2mbtiles-docker
RUN mkdir -p /tmp/src
WORKDIR /tmp/src
Expand Down
8 changes: 6 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ module.exports = {
password:process.env.db_password,
host:process.env.db_host,
port:process.env.db_port,
database:'rwss_assets',
database:process.env.db_name,
},
name: 'WASAC RWSS Vector Tiles',
description: 'Vector tiles for water supply data at Rural Water and Sanitation Services in WASAC, Rwanda',
attribution: '©WASAC, Ltd.',
mbtiles: __dirname + '/data/rwss.mbtiles',
createPmtiles: true,
minzoom: 8,
maxzoom: 14,
layers : [
Expand Down Expand Up @@ -973,4 +977,4 @@ module.exports = {
`
}
],
};
};
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
version: '2'
services:
nodejs:
image: wasac/vt:v0.0.2
# build: .
# image: wasac/vt:v0.0.2
build: .
environment:
- db_user=postgres
- db_password=$db_password
- db_host=host.docker.internal
- db_port=5432
- db_name=rwss_assets
volumes:
- ./data:/tmp/src/data
- ./public:/tmp/src/public
Expand Down
4 changes: 3 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ echo "db_user=${db_user}" > .env
echo "db_password=${db_password}" > .env
echo "db_host=${db_host}" > .env
echo "db_port=${db_port}" > .env
npm run create
echo "db_name=${db_name}" > .env
npm run create
npm run extract
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const generate = async () =>{
const pg2mbtiles = new postgis2mbtiles(config);
const file_mbtile = await pg2mbtiles.run()
console.log(`mbtiles was generated: ${file_mbtile}`);
if (config.createPmtiles) {
config.mbtiles = config.mbtiles.replace('.mbtiles', '.pmtiles')
const pg2pmtiles = new postgis2mbtiles(config);
const file_pmtile = await pg2pmtiles.run()
console.log(`pmtiles was generated: ${file_pmtile}`);
}
console.timeEnd('postgis2mbtiles');
};

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"homepage": "https://github.com/WASAC/vt#readme",
"dependencies": {
"@watergis/mbtiles2pbf": "^0.2.1",
"@watergis/postgis2mbtiles": "^0.1.5",
"@watergis/postgis2mbtiles": "^0.1.6",
"dotenv": "^8.2.0",
"fs": "0.0.1-security",
"gh-pages": "^3.1.0"
}
}
}
Loading