Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from kksudo/develop
Browse files Browse the repository at this point in the history
Release v.0.1.0
  • Loading branch information
kksudo authored Jul 15, 2020
2 parents 582885b + b4ddbfc commit a9ee50c
Show file tree
Hide file tree
Showing 12 changed files with 293 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.*
LICENSE
VERSION
README.md
Changelog.md
Makefile
docker-compose.yml
docs
2 changes: 2 additions & 0 deletions .github/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OD_RELEASE=1.1
OD_MASTER_COMMIT_ID=c3231634c4fe5d8c538c7442c136e7ec4ba0f983
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Problem description

<!--Briefly describe the problem that you found.
Only DOCUMENTATION issues should be filed here.
For general questions, go to https://forums.docker.com/. -->

### Problem location

<!-- Help us find the problem quickly by choosing one of these. -->

- I saw a problem on the following URL: <URL>

- I couldn't find the information I wanted. I expected to find it near the following URL: <URL>

- Other: <DETAILS>

### Project version(s) affected

<!-- If this problem only affects specific versions of a project (like Docker
Engine 1.13), tell us here. The fix may need to take that into account. -->

### Suggestions for a fix

<!--If you have specific ideas about how we can fix this, let us know. -->


<!-- To improve this template, edit the .github/ISSUE_TEMPLATE.md file -->
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md)
for this project's contribution guidelines. Remove these comments
as you go.
DO NOT edit files and directories listed in _data/not_edited_here.yaml.
These are maintained in upstream repos and changes here will be lost.
Help us merge your changes more quickly by adding details and setting metadata
(such as labels, milestones, and reviewers) over at the right-hand side.-->

### Proposed changes

<!--Tell us what you did and why-->

### Unreleased project version (optional)

<!--If this change only applies to an unreleased version of a project, note
that here and base your work on the `vnext-` branch for your project. If
this doesn't apply to this PR, you can remove this whole section.
Set a milestone if appropriate. -->

### Related issues (optional)

<!--Refer to related PRs or issues: #1234, or 'Fixes #1234' or 'Closes #1234'.
Or link to full URLs to issues or pull requests in other Github projects -->
13 changes: 13 additions & 0 deletions .github/debug_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
steps:
- name: ===DEBUG envs===
run: |
echo
echo "❌ Useful icon for check fail step"
echo "✅ Useful icon for check success step"
echo "-- Environment variables ----------------------------------------------"
env
echo "-----------------------------------------------------------------------"
- name: Setup tmate session
uses: mxschmitt/action-tmate@v2
# touch continue or sudo touch /continue to return job
# GitHub workflow on local machine https://github.com/nektos/act
65 changes: 65 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build and push image

on:
repository_dispatch:
types: [release,master]
env:
USER: "kksudo"
DOCKER_IMAGE: "odyssey-docker"
ODYSSEY_GIT_REPO: "yandex/odyssey"
ODYSSEY_MAIN_BRANCH: "master"
DOCKER_REG_GIT: "docker.pkg.github.com"
DOCKER_REPO_GIT: "odyssey-docker/odyssey"
LOCAL_ENV_PATH: ".github/.env"

jobs:
# Add DockerLint Job and validate
buildImage:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@master
- name: Login to gitHub docker registry and pull latest image
run: |
docker login ${DOCKER_REG_GIT} -u ${USER} -p ${{secrets.GH_TOKEN}}
docker pull ${DOCKER_REG_GIT}/${USER}/${DOCKER_REPO_GIT}:develop
- name: Build from new tag
if: ${{ github.event.client_payload.tag }}
run: |
echo "::set-env name=COMMIT_TYPE::${{ github.event.client_payload.tag }}"
echo "New tag=>${{ github.event.client_payload.id }}"
docker build --build-arg ODYSSEY_VERSION=${{ github.event.client_payload.id }} \
-t ${DOCKER_IMAGE}:CI_${GITHUB_RUN_NUMBER} .
- name: Build from latest commit ID
if: ${{ github.event.client_payload.commit }}
run: |
echo "::set-env name=COMMIT_TYPE::$(echo $ODYSSEY_MAIN_BRANCH)"
echo "New latest master commit_id=>${{ github.event.client_payload.id }}"
docker build --build-arg ODYSSEY_VERSION=${ODYSSEY_MAIN_BRANCH} \
-t ${DOCKER_IMAGE}:CI_${GITHUB_RUN_NUMBER} .
- name: Add docker tags and push to GitHub Packages
run: |
TAGS=(develop latest $COMMIT_TYPE ${{ github.event.client_payload.id }} CI_${GITHUB_RUN_NUMBER})
for tag in ${TAGS[*]}
do
docker tag ${DOCKER_IMAGE}:CI_${GITHUB_RUN_NUMBER} ${DOCKER_REG_GIT}/${USER}/${DOCKER_REPO_GIT}:$tag
docker push ${DOCKER_REG_GIT}/${USER}/${DOCKER_REPO_GIT}:$tag
done
- name: Write latest commit to .env
run: |
if [ ${{ github.event.client_payload.tag }} ]
then
sed -i -E "s/(OD_RELEASE=).*$/\1${{ github.event.client_payload.id }}/" $LOCAL_ENV_PATH
elif [ ${{ github.event.client_payload.commit }} ]
then
sed -i -E "s/(OD_MASTER_COMMIT_ID=).*$/\1${{ github.event.client_payload.id }}/" $LOCAL_ENV_PATH
fi
- name: Push latest vars to git
uses: EndBug/add-and-commit@v4
with:
add: ${{env.LOCAL_ENV_PATH}}
author_name: Github actions
author_email: mail@runner.bot
message: "CI_BOT:Image baked:Latest image is ${{ github.event.client_payload.id }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/watch_remote_repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Watching remote repo

on:
schedule:
- cron: '07 * * * *'
push:
branches:
- develop
paths-ignore:
- ".github/.env"
env:
USER: "kksudo"
ODYSSEY_GIT_REPO: "yandex/odyssey"
LOCAL_ENV_PATH: ".github/.env"
jobs:
watch-repo:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@master
- name: Get the latest up-to-date data from a remote repository
id: get_remote_vars
run: |
echo ::set-env name=LATEST_REMOTE_RELEASE::$(echo $(curl --silent https://api.github.com/repos/${ODYSSEY_GIT_REPO}/releases/latest | grep '"tag_name":' | cut -d'"' -f4))
echo ::set-env name=LATEST_REMOTE_MASTER_COMMIT_ID::$(echo $(git ls-remote git://github.com/${ODYSSEY_GIT_REPO}.git HEAD | awk '{ print $1}'))
- name: Get the local vars from .env
id: get_local_vars
uses: falti/dotenv-action@v0.2.4
with:
path: ${{ env.LOCAL_ENV_PATH }}
- name: The official LATEST_RELEASE has been updated
if: env.LATEST_REMOTE_RELEASE != steps.get_local_vars.outputs.od_release
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GH_TOKEN }}
event-type: release
client-payload: '{"id": "${{ env.LATEST_REMOTE_MASTER_COMMIT_ID }}", "tag": "true"}'
- name: The official MASTER branch has been updated
if: env.LATEST_REMOTE_MASTER_COMMIT_ID != steps.get_local_vars.outputs.od_master_commit_id
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GH_TOKEN }}
event-type: master
client-payload: '{"id": "${{ env.LATEST_REMOTE_MASTER_COMMIT_ID }}", "commit": "true"}'

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM ubuntu:focal as builder

ARG ODYSSEY_VERSION=1.1
ENV DEBIAN_FRONTEND noninteractive

WORKDIR /tmp/

RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
gnupg \
lsb-release \
git

RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
gcc \
gdb \
libpam0g-dev \
libssl-dev \
postgresql-server-dev-11 \
valgrind

RUN git clone --branch ${ODYSSEY_VERSION} --depth 1 git://github.com/yandex/odyssey.git \
&& cd odyssey \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& make

WORKDIR /tmp/odyssey
RUN cat odyssey.conf | grep -v -E '^(#.*|)$' > build/sources/odyssey-slim.conf


FROM ubuntu:focal

RUN apt-get update && apt-get install -y --no-install-recommends \
libssl1.1 \
&& apt-get clean

RUN groupadd -r odyssey && useradd -r -g odyssey odyssey

COPY --from=builder /tmp/odyssey/build/sources/odyssey /usr/local/bin/
COPY --from=builder /tmp/odyssey/build/sources/odyssey-slim.conf /etc/odyssey/odyssey.conf

COPY docker-entrypoint.sh /entrypoint.sh

RUN chmod a+x /entrypoint.sh
USER odyssey
ENTRYPOINT ["/entrypoint.sh"]

EXPOSE 5432
CMD ["odyssey"]
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# odyssey-docker
Automated docker builds for github.com/yandex/odyssey
<p align="center">
<img src="logo.png" width="35%" height="35%" /><br>
</p>
<br>

Project status
--------------

Warning: The project is under development.
![master-build](https://github.com/kksudo/odyssey-docker/workflows/master-build/badge.svg?branch=develop)

# Odyssey
Advanced multi-threaded [PostgreSQL](https://www.postgresql.org/) connection pooler and request router.

Odyssey Docker image
======================

Automated docker builds for [yandex/odyssey](https://github.com/yandex/odyssey).
This is a minimal Odyssey image ( [DockerHub](https://hub.docker.com/r/kksudo/odyssey-docker) or [Github packages](https://github.com/kksudo/odyssey-docker/packages/) ), based on Ubuntu Focal.

Features:

* Uses standard Postgres port 5432, to work transparently for applications.
* `/etc/odyssey/odyssey.conf` is auto-created if it don't exist.


Available tags
--------------

Stable tags:

- `1.1` - Image from latest tag in [yandex/odyssey](https://github.com/yandex/odyssey). Latest stable version.
- `master` - Image from latest master branch in [yandex/odyssey](https://github.com/yandex/odyssey). Latest develop version.
- `<commit_id>` - Same as master, but tagged with commit_id.

Tags for development, do not use them.

- `latest` - Latest build in CI.
- `develop` - Latest debug build.
11 changes: 11 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -Eeo pipefail

: ${ODYSSEY_CONF:="/etc/odyssey/odyssey.conf"}

if [[ "${1}" == "odyssey" ]]; then
exec odyssey ${ODYSSEY_CONF}
else
exec ${@}
fi
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a9ee50c

Please sign in to comment.