Skip to content

Commit

Permalink
TRANSFER-886: Draft release routine
Browse files Browse the repository at this point in the history
Build docker for trcli and push it to docker registry

---

Pull Request resolved: #47

Co-authored-by: tserakhau <[email protected]>
commit_hash:b47d3f4b0dfc9a1e756072ac4e10c187bbb32ca4
  • Loading branch information
laskoviymishka authored and robot-piglet committed Sep 16, 2024
1 parent 1abb3be commit 521a0cb
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Auto build and publish of Transfer image

on:
push:
branches:
- 'release-*'
tags:
- 'v*.*.*'

jobs:
trigger-build:
permissions:
contents: write
packages: write
uses: ./.github/workflows/release.yml
with:
version: ${{ github.ref_name }}

39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
workflow_call:
inputs:
version:
description: Version of base Transfer image
required: true
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: doublecloud/transfer
permissions: {}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Dump version
run: |
echo "${{ inputs }}"
echo "${{ inputs.version }}"
- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # @v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # @v5
with:
context: .
push: true
tags: ghcr.io/doublecloud/transfer:${{ inputs.version }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_LABEL=${{ inputs.version }}
3 changes: 3 additions & 0 deletions .mapping.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
".":"cloud/doublecloud/transfer/github_os",
".github/workflows/build_and_test.yml":"cloud/doublecloud/transfer/github_os/.github/workflows/build_and_test.yml",
".github/workflows/dev-release.yml":"cloud/doublecloud/transfer/github_os/.github/workflows/dev-release.yml",
".github/workflows/release.yml":"cloud/doublecloud/transfer/github_os/.github/workflows/release.yml",
".gitignore":"cloud/doublecloud/transfer/github_os/.gitignore",
"CONTRIBUTING.md":"cloud/doublecloud/transfer/github_os/CONTRIBUTING.md",
"Dockerfile":"cloud/doublecloud/transfer/github_os/Dockerfile",
"GLOSSARY.md":"transfer_manager/go/GLOSSARY.md",
"LICENSE":"cloud/doublecloud/transfer/github_os/LICENSE",
"Makefile":"cloud/doublecloud/transfer/github_os/Makefile",
Expand Down
72 changes: 72 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Stage 1: Build Go binary
FROM golang:1.22-alpine AS builder

# Set up environment variables for Go
ENV CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64

# Set the working directory
WORKDIR /app

# Copy the Go modules files
COPY go.mod go.sum ./

# Download Go module dependencies
RUN go mod download

# Copy the source code
COPY . .

# Build the Go binary
RUN go build -o /app/trcli ./transfer_manager/go/cmd/trcli/*.go

# Stage 2: Base image setup (use Ubuntu for the other tools and dependencies)
FROM amd64/ubuntu:jammy

ENV TZ=Etc/UTC

ENV DEBIAN_FRONTEND=noninteractive

RUN echo $TZ > /etc/timezone && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime

# Install required packages
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq && \
apt-get install -y gnupg wget lsb-release curl ca-certificates openssh-client \
iptables supervisor apt-transport-https dirmngr nano vim telnet less tcpdump net-tools \
tzdata lsof libaio1 unzip git && \
# Add PostgreSQL official repository
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql.gpg && \
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
apt-get update -qq && \
apt-get install -y postgresql-client-16 && \
rm -rf /var/lib/apt/lists/*

# Pre-configure debconf to avoid ClickHouse prompts (password or confirmation)
RUN echo "clickhouse-client clickhouse-server/root_password password root" | debconf-set-selections && \
echo "clickhouse-client clickhouse-server/root_password_again password root" | debconf-set-selections

# Install ClickHouse
RUN DEBIAN_FRONTEND=noninteractive apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754 && \
echo "deb https://packages.clickhouse.com/deb stable main" >> /etc/apt/sources.list && \
apt-get update -qq && \
apt-get install -y clickhouse-server=23.5.3.24 clickhouse-client=23.5.3.24 clickhouse-common-static=23.5.3.24 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Create a non-root user and group
RUN addgroup --system trcligroup && adduser --system --ingroup trcligroup trcliuser

# Copy the Go binary from Stage 1 (builder)
COPY --from=builder /app/trcli /usr/local/bin/trcli

RUN chmod +x /usr/local/bin/trcli

# Set ownership of the binary to the non-root user
RUN chown trcliuser:trcligroup /usr/local/bin/trcli

# Switch to the non-root user
USER trcliuser

ENTRYPOINT ["/usr/local/bin/trcli"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ make build
### 3. Using docker container

```shell
docker pull transfer/transfer
docker pull ghcr.io/doublecloud/transfer:dev
```

To run Transfer quickly:

```shell
docker run transfer/transfer activate
docker run ghcr.io/doublecloud/transfer:dev activate --help
```

<div align="center">
Expand Down

0 comments on commit 521a0cb

Please sign in to comment.