Skip to content

Commit

Permalink
Merge pull request #22 from ChillFish8/create-dockerfile-and-wf
Browse files Browse the repository at this point in the history
Create dockerfile and Workflow
  • Loading branch information
ChillFish8 authored Nov 7, 2021
2 parents 9fd94ce + 722f598 commit a1f7734
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '35 8 * * *'
push:
branches: [ master ]
# Publish semver tags as releases.
tags: [ '*.*.*' ]
pull_request:
branches: [ master ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: chillfish8/rewrk


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/[email protected]
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v2
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM chillfish8/rust-builder:latest as builder

WORKDIR /home/rust/

# Avoid having to install/build all dependencies by copying
# the Cargo files and making a dummy src/main.rs
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl

# Size optimization
RUN strip target/x86_64-unknown-linux-musl/release/rewrk

# Start building the final image
FROM scratch
WORKDIR /etc/rewrk

COPY --from=builder /home/rust/target/x86_64-unknown-linux-musl/release/rewrk .
ENTRYPOINT ["./rewrk"]

0 comments on commit a1f7734

Please sign in to comment.