-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
1abb3be
commit 521a0cb
Showing
5 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters