Skip to content

Commit

Permalink
Merge pull request #25 from lecaoquochung/scala
Browse files Browse the repository at this point in the history
Scala
  • Loading branch information
lecaoquochung authored Oct 5, 2024
2 parents a1792f7 + 7048a38 commit c713c64
Show file tree
Hide file tree
Showing 17 changed files with 658 additions and 24 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,39 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: ubuntu-noble
run: docker build . --file ./ubuntu/Dockerfile.noble --tag ubuntu-noble:$(date +%s)
run: docker build . --file ./ubuntu/Dockerfile.noble --tag "ubuntu-noble:$(date +%s)"

build-php-latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: php-fpm
run: docker build . --file ./php/Dockerfile.latest --tag php:$(date +%s)
run: docker build . --file ./php/Dockerfile.latest --tag "php:$(date +%s)"

build-scala-bionic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: scala-bionic
run: docker build . --file ./scala/Dockerfile.bionic --tag scala-bionic:$(date +%s)

run: docker build . --file ./scala/build/Dockerfile.bionic --tag "scala-bionic:$(date +%s)"
build-scala-mantic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: scala-mantic
run: docker build . --file ./scala/Dockerfile.mantic --tag scala-mantic:$(date +%s)
run: docker build . --file ./scala/build/Dockerfile.mantic --tag "scala-mantic:$(date +%s)"
build-scala-maintenance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: scala-maintenance
run: docker build . --file ./scala/build/Dockerfile.maintenance --tag "scala-maintenance:$(date +%s)"


build-jenkins-latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: jenkins-latest
run: docker build . --file ./jenkins/Dockerfile.latest --tag jenkins-latest:$(date +%s)
run: docker build . --file ./jenkins/Dockerfile.latest --tag "jenkins-latest:$(date +%s)"
81 changes: 67 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: ubuntu-lastest
run: docker build . --file ./ubuntu/Dockerfile.latest --tag ubuntu-latest:$(date +%s)
run: docker build . --file ./ubuntu/Dockerfile.latest --tag "ubuntu-latest:$(date +%s)"

# MacOS
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
Expand Down Expand Up @@ -106,14 +106,14 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: ubuntu-qa
run: docker build . --file ./ubuntu/Dockerfile.qa --tag ubuntu-qa:$(date +%s)
run: docker build . --file ./ubuntu/Dockerfile.qa --tag "ubuntu-qa:$(date +%s)"

build-ubuntu-noble:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: ubuntu-noble
run: docker build . --file ./ubuntu/Dockerfile.noble --tag ubuntu-noble:$(date +%s)
run: docker build . --file ./ubuntu/Dockerfile.noble --tag "ubuntu-noble:$(date +%s)"

# PROGRAMMING LANGUAGE
# PHP
Expand All @@ -122,27 +122,40 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: php-fpm
run: docker build . --file ./php/Dockerfile.latest --tag php:$(date +%s)
run: docker build . --file ./php/Dockerfile.latest --tag "php:$(date +%s)"
build-php-beta:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: php-fpm
run: docker build . --file ./php/Dockerfile.beta --tag php:$(date +%s)
run: docker build . --file ./php/Dockerfile.beta --tag "php:$(date +%s)"

# SCALA
build-scala-latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: scala-latest
run: docker build . --file ./scala/build/Dockerfile.latest --tag "scala-latest:$(date +%s)"
build-scala-bionic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: scala-bionic
run: docker build . --file ./scala/Dockerfile.bionic --tag scala-bionic:$(date +%s)
run: docker build . --file ./scala/build/Dockerfile.bionic --tag "scala-bionic:$(date +%s)"
build-scala-mantic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: scala-mantic
run: docker build . --file ./scala/Dockerfile.mantic --tag scala-mantic:$(date +%s)
run: docker build . --file ./scala/build/Dockerfile.mantic --tag "scala-mantic:$(date +%s)"
build-scala-maintenance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: scala-maintenance
run: docker build . --file ./scala/build/Dockerfile.maintenance --tag "scala-maintenance:$(date +%s)"


# APPLICATIONS
# JENKINS
Expand Down Expand Up @@ -284,7 +297,6 @@ jobs:
./setup.sh startup || { echo "Redash startup failed"; exit 1; }
./setup.sh || { echo "Redash setup failed"; exit 1; }
# TEST REDASH DOCKER
test-redash-docker:
needs: build-windows-latest
Expand Down Expand Up @@ -322,28 +334,69 @@ jobs:
- name: Test Redash
working-directory: ./redash
run: |
# Init
docker compose run --rm redash-server create_db
# Should response
# [2024-09-29 02:43:15,704][PID:1][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
# [2024-09-29 02:43:15,704][PID:1][INFO][alembic.runtime.migration] Will assume transactional DDL.
# [2024-09-29 02:43:16,124][PID:1][INFO][alembic.runtime.migration] Running stamp_revision -> 89bc7873a3e0
# NEED REPORT - Github Action Windows latest runner not supported
# no matching manifest for windows/amd64 10.0.20348 in the manifest list entries
# https://github.com/lecaoquochung/docker-images/actions/runs/11089568047/job/30810875892#step:6:25
# Start
docker compose up -d
docker compose ps
docker compose logs
# should response
# docker-images-redash-worker | Starting RQ scheduler...
# docker-images-redash-server | [2024-09-29 02:43:27 +0000] [1] [INFO] Starting gunicorn 20.0.4
# docker-images-redash-server | [2024-09-29 02:43:27 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
# verify localhost:5500 response by curl
# Test
# Verify localhost:5500 response by curl
# npm install -g wait-on
# npx wait-on http://localhost:5500 -t 60000 -l
# curl http://localhost:5500 -vd
# TEST SCALA CODING
# test-scala-coding:
# needs: build-scala-latest
# runs-on: ubuntu-latest
# environment: CI
# steps:
# - uses: actions/checkout@v4
# - name: ENV
# run: |
# env
# - name: Environment variables
# run: |
# echo "Github environment indirect : $CONTACT_VAR"
# echo "Github environment direct : " ${{ vars.CONTACT }}
# env:
# CONTACT_VAR: ${{ vars.CONTACT }}
# - name: Dependencies
# run: |
# sudo apt-get update
# - name: Run test
# working-directory: ./scala/coding
# run: |
# ls -all
# sbt test

test-scala-coding:
needs: build-scala-latest
runs-on: ubuntu-latest
environment: CI
steps:
- uses: actions/checkout@v4
- name: Set up Scala and sbt
uses: olafurpg/setup-scala@v14
with:
java-version: [email protected]
- name: Run tests
working-directory: ./scala/coding
run: |
sbt clean coverage test coverageReport
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
File renamed without changes.
191 changes: 191 additions & 0 deletions scala/build/Dockerfile.latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Release: https://releases.ubuntu.com
# Wiki: https://wiki.ubuntu.com/Releases
# FROM ubuntu:oracular
FROM ubuntu:24.10

# Maintainer information
LABEL maintainer="[email protected]"

# Docker Engine https://docs.docker.com/engine/
ARG DOCKER_VERSION=27.3
ARG DOCKER_COMPOSE_VERSION=2.29.7
ARG AWS_CLI_VERSION=2.13.5
ARG QA_PATH="/home/qa/code"

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PATH="/home/qa/.yarn/bin:/home/qa/.local/bin:${PATH}"
ENV QA_PATH=${QA_PATH}

# Update package index and install system dependencies
RUN apt-get update && apt-get install -y \
git curl iputils-ping telnet vim gnupg unzip wget python3 python3-venv \
postgresql-client default-jre default-jdk apt-transport-https ca-certificates \
software-properties-common chromium-bsu chromium-browser xvfb python3-full \
make build-essential
# TODO Build by installing package with specific version
# RUN apt-get update && apt-get install -y --no-install-recommends \
# git=1:2.34.1-1ubuntu1.10 \
# curl=7.81.0-1ubuntu1.15 \
# iputils-ping=3:20211215-1 \
# telnet=0.17-44build1 \
# vim=2:8.2.3995-1ubuntu2.15 \
# gnupg=2.2.27-3ubuntu2.1 \
# unzip=6.0-26ubuntu3.1 \
# wget=1.21.2-2ubuntu1 \
# python3=3.10.6-1~22.04 \
# python3-venv=3.10.6-1~22.04 \
# postgresql-client=14+238 \
# default-jre=2:1.11-72build2 \
# default-jdk=2:1.11-72build2 \
# apt-transport-https=2.4.10 \
# ca-certificates=20230311ubuntu0.22.04.1 \
# software-properties-common=0.99.22.9 \
# chromium-browser=120.0.6099.129-0ubuntu0.22.04.1 \
# xvfb=2:21.1.4-2ubuntu1.7~22.04.1 \
# python3-full=3.10.6-1~22.04 \
# make=4.3-4.1build1 \
# build-essential=12.9ubuntu3 \
# && rm -rf /var/lib/apt/lists/*

# Create a virtual environment
# Activate the virtual environment
# Upgrade pip within the virtual environment
# Copy the requirements file into the container
# Install dependencies from the requirements file
# RUN python3 -m venv /venv
# ENV PATH="/venv/bin:$PATH"
# RUN pip install --upgrade pip
# COPY scala/build/requirements.txt .
# RUN pip install -r requirements.txt
COPY scala/build/requirements.txt /tmp/requirements.txt
RUN python3 -m venv /venv && \
. /venv/bin/activate && \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /tmp/requirements.txt && \
rm /tmp/requirements.txt
ENV PATH="/venv/bin:$PATH"


# Install Yarn
# Install Node.js and utilities
# RUN npm install -g npm@latest
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
# echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
# apt-get update && \
# apt-get install -y yarn
# RUN apt-get install -y nodejs npm && \
# npm install -g n
# RUN n stable

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
# apt-get install -y --no-install-recommends yarn=<version> nodejs=<version> npm=<version> && \
# apt-get install -y --no-install-recommends yarn=1.22.22 nodejs=22.9.0 npm=10.9.0 && \
apt-get install -y --no-install-recommends yarn nodejs npm && \
npm install -g n && \
n 22.9.0 && \
npm cache clean --force && \
yarn cache clean && \
rm -rf /var/lib/apt/lists/*

# TODO - update to yarn 2
# https://yarnpkg.com/getting-started/install

# Install AWS CLI
# RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
# unzip awscliv2.zip && \
# ./aws/install && \
# rm -rf awscliv2.zip ./aws
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm -rf awscliv2.zip ./aws

# Install Docker and Docker Compose
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \
apt-get update && \
apt-get install -y docker-ce docker-ce-cli containerd.io && \
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose

# TODO build docker engine with specific version
# https://docs.docker.com/engine/install/ubuntu/
# RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
# add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \
# apt-get update && \
# apt-get install -y --no-install-recommends \
# docker-ce=${DOCKER_VERSION} \
# docker-ce-cli=${DOCKER_VERSION} \
# containerd.io && \
# curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
# chmod +x /usr/local/bin/docker-compose && \
# rm -rf /var/lib/apt/lists/*
# Logs: https://github.com/lecaoquochung/docker-images/pull/25#discussion_r1788462147

# RUN apt-get update && \
# apt-get install -y \
# ca-certificates \
# curl \
# gnupg \
# lsb-release && \
# mkdir -p /etc/apt/keyrings && \
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
# echo "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
# tee /etc/apt/sources.list.d/docker.list > /dev/null && \
# apt-get update && \
# apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# LOGS: docker compose / docker-compose

# Setup application directory
RUN mkdir -p /home/qa/Downloads /app /home/qa/code && \
chown -R 1000:1000 /home/qa

# Set work directory
WORKDIR /home/qa/code

# Install Node & Yarn dependencies
RUN yarn install && \
yarn global add junit-report-merger && \
yarn cache clean

# Install trcli and Playwright
RUN pip install --no-cache-dir trcli && \
npx playwright install

# Version check and other commands
# RUN date && pwd && ls && \
# docker --version && \
# npm --version && \
# yarn --version && \
# trcli && \
# npx playwright --version
# TODO CI build test
# RUN yarn install && \
# yarn global add junit-report-merger && \
# yarn cache clean && \
# pip install --no-cache-dir trcli && \
# npx playwright install && \
# docker --version && \
# npm --version && \
# yarn --version && \
# trcli --version && \
# npx playwright --version
# Check Available Package Versions:
# If you prefer to specify exact versions, you can list available versions for docker-ce and docker-ce-cli using the following commands:
# apt-cache madison docker-ce
# apt-cache madison docker-ce-cli

# Start command (example: running a server, for instance)
CMD ["bash"]

# This build is for testing purpose only
# For production application with scala
# Replace /app/your-scala-app.jar with the actual path to your Scala application's JAR file.
# CMD ["java", "-jar", "/app/your-scala-app.jar"]
# Alternatively, you could use an ENTRYPOINT script that performs any necessary setup and then runs your application:
# COPY entrypoint.sh /entrypoint.sh
# RUN chmod +x /entrypoint.sh
# ENTRYPOINT ["/entrypoint.sh"]
Loading

0 comments on commit c713c64

Please sign in to comment.