-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dockerize runner and database service
Create a database service in the action Create a local dockerfile for runner Connect to zoning-api network
- Loading branch information
1 parent
5ac2b69
commit 8d9f932
Showing
11 changed files
with
202 additions
and
154 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,96 @@ | ||
on: [push] | ||
|
||
jobs: | ||
etl: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgis/postgis:15-3.4-alpine | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
# Maps tcp port 5432 on service container to the host | ||
- 5432:5432 | ||
steps: | ||
- name: check out repo code | ||
uses: actions/checkout@v4 | ||
- name: Load Secrets | ||
uses: 1password/load-secrets-action@v1 | ||
with: | ||
export-env: true | ||
env: | ||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | ||
DO_SPACES_ENDPOINT: "op://AE Data Flow/Digital Ocean - S3 file storage/DO_SPACES_ENDPOINT" | ||
DO_SPACES_ACCESS_KEY: "op://AE Data Flow/Digital Ocean - S3 file storage/DO_SPACES_ACCESS_KEY" | ||
DO_SPACES_SECRET_KEY: "op://AE Data Flow/Digital Ocean - S3 file storage/DO_SPACES_SECRET_KEY" | ||
DO_SPACES_BUCKET_DISTRIBUTIONS: "op://AE Data Flow/Digital Ocean - S3 file storage/DO_SPACES_BUCKET_DISTRIBUTIONS" | ||
DO_ZONING_API_DB_HOST: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API/host" | ||
DO_ZONING_API_DB_PORT: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API/port" | ||
DO_ZONING_API_DB_USERNAME_DEV: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API dev/username" | ||
DO_ZONING_API_DB_PASSWORD_DEV: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API dev/password" | ||
DO_ZONING_API_DB_DATABASE_DEV: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API dev/database" | ||
- name: Set .env file | ||
run: | | ||
echo "BUILD_ENGINE_HOST=127.0.0.1" >> .env | ||
echo "BUILD_ENGINE_PORT=5432" >> .env | ||
echo "BUILD_ENGINE_USER=postgres" >> .env | ||
echo "BUILD_ENGINE_PASSWORD=postgres" >> .env | ||
echo "BUILD_ENGINE_DB=postgres" >> .env | ||
echo "DO_SPACES_ENDPOINT=$DO_SPACES_ENDPOINT" >> .env | ||
echo "DO_SPACES_ACCESS_KEY=$DO_SPACES_ACCESS_KEY" >> .env | ||
echo "DO_SPACES_SECRET_KEY=$DO_SPACES_SECRET_KEY" >> .env | ||
echo "DO_SPACES_BUCKET_DISTRIBUTIONS=$DO_SPACES_BUCKET_DISTRIBUTIONS" >> .env | ||
echo "ZONING_API_HOST=$DO_ZONING_API_DB_HOST" >> .env | ||
echo "ZONING_API_PORT=$DO_ZONING_API_DB_PORT" >> .env | ||
echo "ZONING_API_USER=$DO_ZONING_API_DB_USERNAME_DEV" >> .env | ||
echo "ZONING_API_PASSWORD=$DO_ZONING_API_DB_PASSWORD_DEV" >> .env | ||
echo "ZONING_API_DB=$DO_ZONING_API_DB_DATABASE_DEV" >> .env | ||
- name: Install prerequisite packages | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y wget | ||
sudo apt-get install -y git | ||
- name: Setup PostgreSQL | ||
uses: tj-actions/install-postgresql@v3 | ||
with: | ||
postgresql-version: 15 | ||
|
||
- name: Check postgres install | ||
run: pg_dump --version | ||
|
||
- name: Install minio client | ||
run: | | ||
sudo wget https://dl.min.io/client/mc/release/linux-amd64/mc | ||
sudo chmod +x mc | ||
sudo mv mc /usr/local/bin | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: ".python-version" | ||
|
||
- name: Install python dependencies | ||
run: pip install -r requirements.txt | ||
|
||
- name: Install dbt dependencies | ||
run: dbt deps | ||
|
||
- name: Download | ||
run: ./bash/download.sh | ||
|
||
- name: Import | ||
run: ./bash/import.sh | ||
|
||
- name: Transform | ||
run: ./bash/transform.sh | ||
|
||
- name: Export | ||
run: ./bash/export.sh | ||
|
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,48 @@ | ||
FROM ubuntu:latest | ||
|
||
RUN apt-get update | ||
|
||
# RUN apt install -y wget gpg gnupg2 software-properties-common apt-transport-https lsb-release ca-certificates | ||
RUN apt-get install -y wget | ||
RUN apt-get install -y software-properties-common | ||
|
||
# psql from postgres-client | ||
RUN sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | ||
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | ||
RUN apt-get update | ||
RUN apt-get install -y postgresql-client-15 | ||
|
||
|
||
# minio client | ||
RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc | ||
RUN chmod +x mc | ||
RUN mv mc /usr/local/bin | ||
|
||
# python | ||
COPY requirements.txt /requirements.txt | ||
RUN apt-get install -y python3 python3-pip | ||
RUN pip install -r requirements.txt | ||
|
||
# dbt | ||
## config | ||
COPY dbt_project.yml /dbt_project.yml | ||
COPY package-lock.yml /package-lock.yml | ||
COPY packages.yml /packages.yml | ||
COPY profiles.yml /profiles.yml | ||
## install | ||
RUN apt-get install -y git | ||
RUN dbt deps | ||
## tests | ||
COPY tests /tests | ||
|
||
# etl | ||
## scripts | ||
COPY bash ./bash | ||
## commands | ||
COPY sql /sql | ||
## local source files | ||
COPY borough.csv /borough.csv | ||
COPY land_use.csv /land_use.csv | ||
COPY zoning_district_class.csv /zoning_district_class.csv | ||
|
||
CMD ["sleep", "infinity"] |
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 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 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,13 +1,34 @@ | ||
services: | ||
db: | ||
container_name: ${BUILD_ENGINE_CONTAINER_NAME} | ||
build: | ||
context: ./db | ||
context: db/. | ||
environment: | ||
- POSTGRES_USER=${BUILD_ENGINE_USER} | ||
- POSTGRES_PASSWORD=${BUILD_ENGINE_PASSWORD} | ||
- POSTGRES_DB=${BUILD_ENGINE_DB} | ||
networks: | ||
- data | ||
ports: | ||
- "8001:5432" | ||
runner: | ||
build: | ||
context: . | ||
env_file: | ||
- .env | ||
networks: | ||
- data | ||
data-flow: | ||
build: | ||
context: . | ||
env_file: | ||
- .env | ||
networks: | ||
- data | ||
volumes: | ||
- ./db-volume:/var/lib/postgresql/data | ||
- ./tests:/tests | ||
- ./bash:/bash | ||
- ./sql:/sql | ||
networks: | ||
data: | ||
name: ae-zoning-api_data | ||
external: true |
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,4 +1,4 @@ | ||
FROM postgis/postgis:15-3.4 | ||
FROM postgres:15-bookworm | ||
|
||
RUN apt update | ||
RUN apt install -y postgresql-15-postgis-3 | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.