Skip to content

Commit

Permalink
Build Docker images via GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
hfxbse committed Nov 19, 2024
1 parent 0051ab5 commit 1fcf87c
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 4 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build-airflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: build-airflow
run-name: "Build Airflow container image"
on:
push:
paths:
- airflow.Dockerfile
- airflow/**
- spark/**

jobs:
build-container-image:
runs-on: ubuntu-latest

permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4
name: "Checkout repository"

- uses: VaultVulp/gp-docker-action@1.6.0
name: "Build and upload Docker image"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
image-name: airflow
build-context: ./
dockerfile: airflow.Dockerfile
26 changes: 26 additions & 0 deletions .github/workflows/build-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build-frontend
run-name: "Build frontend container image"
on:
push:
paths:
- frontend/**

jobs:
build-container-image:
runs-on: ubuntu-latest

permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4
name: "Checkout repository"

- uses: VaultVulp/gp-docker-action@1.6.0
name: "Build and upload Docker image"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
image-name: frontend
build-context: frontend/
dockerfile: frontend/Dockerfile
26 changes: 26 additions & 0 deletions .github/workflows/build-hadoop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build-hadoop
run-name: "Build Hadoop container image"
on:
push:
paths:
- hadoop.Dockerfile

jobs:
build-container-image:
runs-on: ubuntu-latest

permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4
name: "Checkout repository"

- uses: VaultVulp/gp-docker-action@1.6.0
name: "Build and upload Docker image"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
image-name: hadoop
build-context: ./
dockerfile: hadoop.Dockerfile
8 changes: 8 additions & 0 deletions Dockerfile.airflow → airflow.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
FROM marcelmittelstaedt/airflow:latest

LABEL org.opencontainers.image.source=https://github.com/hfxbse/dhbw-big-data

ENV HADOOP_HOST="hadoop"

RUN sed -i '34,41d' /startup.sh
RUN sed -i '3 i service ssh start' /startup.sh
RUN git clone --depth 1 https://github.com/marcelmittelstaedt/BigData.git /tmp/upstream
RUN wget https://jdbc.postgresql.org/download/postgresql-42.7.4.jar -P /home/airflow/spark/jars/
RUN mv /tmp/upstream/exercises/winter_semester_2024-2025/05_airflow/plugins /home/airflow/airflow
RUN mv /tmp/upstream/exercises/winter_semester_2024-2025/05_airflow/dags /home/airflow/airflow
RUN mv /tmp/upstream/exercises/winter_semester_2024-2025/05_airflow/python /home/airflow/airflow
RUN sed -i 's/hadoop:/${HADOOP_HOST}:/g' /home/airflow/hadoop/etc/hadoop/core-site.xml
RUN sed -i 's/hadoop:/${HADOOP_HOST}:/g' /home/airflow/hadoop/etc/hadoop/yarn-site.xml

COPY airflow/ /home/airflow/airflow/
COPY spark/ /home/airflow/airflow/python/
RUN chown -R airflow /home/airflow/airflow
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ services:
- "5432:5432"

hadoop:
build:
dockerfile: Dockerfile.hadoop
ports:
- "9864:9864"
- "10000:10000"
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ services:

hadoop:
build:
dockerfile: Dockerfile.hadoop
dockerfile: hadoop.Dockerfile
ports:
- "8088:8088"
- "9870:9870"

airflow:
build:
dockerfile: Dockerfile.airflow
dockerfile: airflow.Dockerfile
depends_on:
user-db:
condition: service_started
Expand Down
2 changes: 2 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM node:20-alpine

LABEL org.opencontainers.image.source=https://github.com/hfxbse/dhbw-big-data

RUN mkdir /app
WORKDIR /app

Expand Down
5 changes: 5 additions & 0 deletions Dockerfile.hadoop → hadoop.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM marcelmittelstaedt/spark_base:latest

LABEL org.opencontainers.image.source=https://github.com/hfxbse/dhbw-big-data

RUN sed -i '44,50 s/^#//' /startup.sh
RUN head -n -9 /startup.sh > temp.sh ; mv temp.sh /startup.sh
RUN echo "echo executing hiveserver2; sudo -u hadoop -H sh -c /home/hadoop/hive/bin/hiveserver2" >> /startup.sh
RUN chmod +x /startup.sh

RUN sed -i 's/hadoop:/0.0.0.0:/g' /home/hadoop/hadoop/etc/hadoop/core-site.xml

HEALTHCHECK --start-interval=10s --start-period=10s --retries=7 \
CMD /bin/sh -c "exit $((4 - $(ps aux | grep -c org.apache.hive.service.server.HiveServer2)))"

0 comments on commit 1fcf87c

Please sign in to comment.