Merge pull request #49 from arghyadipchak/master
Automated docker build for DockerHub + updated cargo.toml
This commit is contained in:
commit
60aac1aea7
3 changed files with 87 additions and 26 deletions
50
.github/workflows/docker.yml
vendored
Normal file
50
.github/workflows/docker.yml
vendored
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
name: Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker_image:
|
||||||
|
name: Build & push docker image to DockerHub
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: ${{ secrets.DOCKERHUB_REPO }}
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
|
- name: Setup QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login DockerHub
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build & push
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64, linux/arm64
|
||||||
|
push: ${{ github.ref_type == 'tag' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
|
@ -11,8 +11,6 @@ repository = "https://github.com/szabodanika/microbin"
|
||||||
keywords = ["pastebin", "pastabin", "microbin", "actix", "selfhosted"]
|
keywords = ["pastebin", "pastabin", "microbin", "actix", "selfhosted"]
|
||||||
categories = ["pastebins"]
|
categories = ["pastebins"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4"
|
actix-web = "4"
|
||||||
actix-files = "0.6.0"
|
actix-files = "0.6.0"
|
||||||
|
@ -34,3 +32,6 @@ actix-web-httpauth = "0.6.0"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
syntect = "5.0"
|
syntect = "5.0"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
|
strip = true
|
||||||
|
|
34
Dockerfile
34
Dockerfile
|
@ -1,23 +1,33 @@
|
||||||
# latest rust will be used to build the binary
|
FROM rust:latest as build
|
||||||
FROM rust:latest as builder
|
|
||||||
|
|
||||||
# the temporary directory where we build
|
WORKDIR /app
|
||||||
WORKDIR /usr/src/microbin
|
|
||||||
|
|
||||||
# copy sources to /usr/src/microbin on the temporary container
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# run release build
|
RUN \
|
||||||
RUN cargo build --release
|
DEBIAN_FRONTEND=noninteractive \
|
||||||
|
apt-get update &&\
|
||||||
|
apt-get -y install ca-certificates tzdata &&\
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
# https://hub.docker.com/r/bitnami/minideb
|
# https://hub.docker.com/r/bitnami/minideb
|
||||||
FROM bitnami/minideb:latest
|
FROM bitnami/minideb:latest
|
||||||
|
|
||||||
# microbin will be in /usr/local/bin/microbin/
|
# microbin will be in /app
|
||||||
WORKDIR /usr/local/bin
|
WORKDIR /app
|
||||||
|
|
||||||
|
# copy time zone info
|
||||||
|
COPY --from=build \
|
||||||
|
/usr/share/zoneinfo \
|
||||||
|
/usr/share/zoneinfo
|
||||||
|
|
||||||
|
COPY --from=build \
|
||||||
|
/etc/ssl/certs/ca-certificates.crt \
|
||||||
|
/etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
||||||
# copy built exacutable
|
# copy built exacutable
|
||||||
COPY --from=builder /usr/src/microbin/target/release/microbin /usr/local/bin/microbin
|
COPY --from=build \
|
||||||
|
/app/target/release/microbin \
|
||||||
|
/usr/bin/microbin
|
||||||
|
|
||||||
# run the binary
|
ENTRYPOINT ["microbin"]
|
||||||
CMD ["microbin"]
|
|
Loading…
Reference in a new issue