forked from CSML-by-Clevy/csml-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: docker build and publish on dockerhub
- Loading branch information
Showing
6 changed files
with
151 additions
and
62 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,8 @@ | ||
.git/ | ||
target/ | ||
**/target/ | ||
Dockerfile | ||
.dockerignore | ||
|
||
!target/release/csml_server | ||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Publish crates.io | ||
name: Publish CSML Engine to crates.io | ||
|
||
on: | ||
release: | ||
|
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,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 |
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,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 |
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