Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
galeaspablo committed Nov 8, 2024
0 parents commit 5ef53f3
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish Docker image

on:
release:
types: [published]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ambarltd
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ambarltd/emulator

- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./build/
file: ./build/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


24 changes: 24 additions & 0 deletions .github/workflows/pr_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PR Test

on:
pull_request_target:
types: [opened, synchronize, reopened ]

permissions:
contents: write
pull-requests: write
id-token: write

jobs:
pr_test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Run Tests
working-directory: build
run: ./test.sh
22 changes: 22 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test

on:
push:
branches: [ main ]

permissions:
contents: write
pull-requests: write
id-token: write

jobs:
test:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Run Tests
working-directory: build
run: ./test.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2024] [Ambar]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added README.md
Empty file.
6 changes: 6 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Security Policy

Please report (suspected) security vulnerabilities to [email protected].
You will receive a response from us within 72 hours.
If the issue is confirmed, we will release a patch as soon as possible.
Note that this project is associated but not exactly the same as PGT-Proxy, which lives in a separate repository.
56 changes: 56 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM alpine:3.19 AS haskell-base

RUN apk update
RUN apk add libffi-dev
RUN apk add ncurses-dev
RUN apk add libpq-dev
RUN apk add gmp-dev
RUN apk add zlib-dev
RUN apk add libc-dev
RUN apk add musl-dev

##################################################################################
##################################################################################
##################################################################################

FROM haskell-base AS haskell-build

RUN apk add git
RUN apk add curl
RUN apk add binutils-gold
RUN apk add gcc
RUN apk add g++
RUN apk add make
RUN apk add perl
RUN apk add pkgconfig
RUN apk add tar
RUN apk add xz

RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
BOOTSTRAP_HASKELL_GHC_VERSION="9.10.1" \
BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 \
sh

ENV PATH="/root/.ghcup/bin:$PATH"
ENV PATH="/root/.cabal/bin:$PATH"

WORKDIR /tmp
RUN git clone https://github.com/ambarltd/emulator.git
RUN mv /tmp/emulator /opt/emulator

WORKDIR /opt/emulator
RUN git fetch # just in case we have cached git clone
RUN git checkout v1.1
RUN cabal build emulator
RUN cp $(cabal list-bin emulator) /tmp/emulator

##################################################################################
##################################################################################
##################################################################################

FROM haskell-base AS final

COPY --from=haskell-build /tmp/emulator /opt/emulator/emulator

ENTRYPOINT ["/opt/emulator/emulator"]
15 changes: 15 additions & 0 deletions build/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
set -e

printf "\n"
echo "============================================"
echo "Docker Build and Sanity Check Run"
echo "============================================"
docker build -t emu8190 .
echo "Expecting help output with client-ca-roots-path line:"
docker run -t emu8190 --help | grep "Connect your databases to multiple consumers with minimal configuration and no libraries needed"
echo "============================================"
echo "Docker Build and Sanity Check Passed"
echo "============================================"
printf "\n\n\n\n\n"
echo "Sanity check passed. Congratulations. Bye!"

0 comments on commit 5ef53f3

Please sign in to comment.