Skip to content

Commit

Permalink
Merge pull request #2 from zhiweio/feature/docker
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiweio authored Jul 13, 2024
2 parents f41cfad + addca75 commit fa328d2
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 3 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Docker Image Build

on:
workflow_dispatch:
inputs:
version:
description: The version to build

push:
tags:
- '*.*'
- '*.*.*'

jobs:

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/streamxfer:latest
80 changes: 80 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
FROM amazonlinux:latest

LABEL maintainer="Wang Zhiwei <[email protected]>"


# Install necessary packages for locales
RUN yum update -y && \
yum clean metadata && \
yum install -y glibc-langpack-en

ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8

RUN locale


# Install Python 3.9
RUN yum -y install \
wget \
tar \
gzip \
make \
gcc \
openssl-devel \
bzip2-devel \
libffi-devel \
sqlite-devel \
zip \
unzip \
lzop \
git \
which \
zlib-devel

WORKDIR /opt

RUN wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz
RUN tar xzf Python-3.9.7.tgz

WORKDIR /opt/Python-3.9.7

RUN ./configure --enable-optimizations
RUN make altinstall

WORKDIR /

RUN rm -rf /opt/Python-3.9.7*

RUN ln -s $(which python3.9) /usr/local/bin/python3
RUN python3 -m pip install -U pip


# Install mssql-tools
RUN curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo && \
yum remove mssql-tools unixODBC-utf16 unixODBC-utf16-devel && \
ACCEPT_EULA=Y yum install -y mssql-tools18 unixODBC-devel
RUN echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
RUN yum clean all


# Install AWS CLI
WORKDIR /opt

RUN yum remove awscli
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN unzip awscliv2.zip

RUN ./aws/install

WORKDIR /

RUN rm -rf /opt/aws*


# Install StreamXfer
RUN python3 -m pip install -U git+https://github.com/zhiweio/streamxfer@master


CMD ["/bin/bash"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Before installing StreamXfer, you need to install the following dependencies:

* mssql-tools: [SQL Docs - bcp Utility](https://learn.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-ver16)
* lzop: [Download](https://www.lzop.org/)
* awscli: [AWS CLI install and update instructions](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions)

Then, install StreamXfer from PyPI:

Expand Down
9 changes: 6 additions & 3 deletions streamxfer/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

from streamxfer.typing import *
from streamxfer.cmd import Cat
from streamxfer.cmd import Cat, raise_if_not_exists


class BaseSink:
Expand All @@ -26,15 +26,18 @@ class LocalSink(BaseSink):
bin = Cat.bin

def cmd(self) -> Union[List[str], str]:
raise_if_not_exists(self.bin)
_cmd = [self.bin, ">", self.uri]
return " ".join(_cmd)


class S3Sink(BaseSink):
bin = "aws s3 cp"
bin = "aws"
subcommand = "s3 cp"

def cmd(self) -> Union[List[str], str]:
_cmd = [self.bin, "-", self.uri]
raise_if_not_exists(self.bin)
_cmd = [self.bin, self.subcommand, "-", self.uri]
return " ".join(_cmd)


Expand Down

0 comments on commit fa328d2

Please sign in to comment.