Skip to content

Commit

Permalink
feat: docker build and publish on dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
frsechet committed Oct 15, 2020
1 parent 92c987d commit 4cf19ea
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 62 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
target/
**/target/
Dockerfile
.dockerignore

!target/release/csml_server

55 changes: 0 additions & 55 deletions .github/workflows/bin.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/cratesio.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish crates.io
name: Publish CSML Engine to crates.io

on:
release:
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Publish CSML Server Packages

on:
release:
types: [published]

jobs:
build:
runs-on: ${{ matrix.os }}
env:
MACOSX_DEPLOYMENT_TARGET: 10.11
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
asset_name: csml-server-linux-amd64
- os: macos-latest
asset_name: csml-server-macos-amd64

steps:
- uses: actions/checkout@v2

# for some reason cache does not work properly with macos builds
- name: Cache Cargo
if: matrix.os != 'macos-latest'
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-csml-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install Rust Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Build Server
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --manifest-path=csml_server/Cargo.toml --features csml_engine/mongo,csml_engine/dynamo --release

- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.asset_name }}
path: target/release/csml_server




publish-binaries:
runs-on: ${{ matrix.os }}
needs: build
env:
MACOSX_DEPLOYMENT_TARGET: 10.11
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
asset_name: csml-server-linux-amd64
- os: macos-latest
asset_name: csml-server-macos-amd64

steps:
- run: mkdir -p target/release
- uses: actions/download-artifact@v2
with:
name: ${{ matrix.asset_name }}
path: target/release

- name: Upload binary to release
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/csml_server
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}
overwrite: true



publish-docker:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- run: mkdir -p target/release
- uses: actions/download-artifact@v2
with:
name: csml-server-linux-amd64
path: target/release

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

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
clevy/csml-engine:latest
clevy/csml-engine:${{ github.ref }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:18.04

WORKDIR /usr/src/csml

COPY ./target/release/csml_server server

RUN chmod 755 server

RUN groupadd -r csml && useradd -r -g csml csml
USER csml

EXPOSE 5000

CMD ./server
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
<h4 align="center">First programming language dedicated to building chatbots.</h4>

<p align="center">
<img src="https://github.com/CSML-by-Clevy/csml-engine/workflows/Rust/badge.svg"
alt="Rust">
<a href="https://join.slack.com/t/csml-by-clevy/shared_invite/enQtODAxMzY2MDQ4Mjk0LWZjOTZlODI0YTMxZTg4ZGIwZDEzYTRlYmU1NmZjYWM2MjAwZTU5MmU2NDdhNmU2N2Q5ZTU2ZTcxZDYzNTBhNTc"><img src="https://img.shields.io/badge/slack-CSML-blue.svg?logo=slack" alt="Slack"></a>
<img src="https://img.shields.io/github/commits-since/CSML-by-Clevy/csml-engine/v1.0.0">
<img src="https://img.shields.io/badge/Docs-up--to--date-brightgreen">

<img src="https://github.com/CSML-by-Clevy/csml-engine/workflows/Rust/badge.svg" alt="Rust">
<a href="https://github.com/CSML-by-Clevy/csml-engine/releases/latest"><img alt="GitHub release (latest by date)" src="https://img.shields.io/github/v/release/csml-by-clevy/csml-engine?label=latest%20release&logo=Latest%20release"></a>
<a href="https://hub.docker.com/r/clevy/csml-engine"><img alt="Docker Image Version (latest semver)" src="https://img.shields.io/docker/v/clevy/csml-engine?sort=semver"></a>
<a href="https://join.slack.com/t/csml-by-clevy/shared_invite/enQtODAxMzY2MDQ4Mjk0LWZjOTZlODI0YTMxZTg4ZGIwZDEzYTRlYmU1NmZjYWM2MjAwZTU5MmU2NDdhNmU2N2Q5ZTU2ZTcxZDYzNTBhNTc"><img src="https://img.shields.io/badge/slack-CSML-blue.svg?logo=slack" alt="Slack"></a>
</p>

<p align="center">
Expand Down

0 comments on commit 4cf19ea

Please sign in to comment.