mirror of
https://github.com/Hopiu/lychee.git
synced 2026-03-16 20:50:25 +00:00
Add official Docker image #40
This commit is contained in:
parent
1f787613d4
commit
936c5440b1
4 changed files with 98 additions and 0 deletions
4
.dockerignore
Normal file
4
.dockerignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.git
|
||||
target
|
||||
assets
|
||||
fixtures
|
||||
21
.github/workflows/docker.yml
vendored
Normal file
21
.github/workflows/docker.yml
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
name: Publish Docker Image
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Publish to Registry
|
||||
uses: elgohr/Publish-Docker-Github-Action@3.01
|
||||
with:
|
||||
name: lycheeverse/lychee
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
snapshot: true
|
||||
tag_semver: true
|
||||
46
Dockerfile
Normal file
46
Dockerfile
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
FROM rust:latest as builder
|
||||
|
||||
RUN USER=root cargo new --bin lychee
|
||||
WORKDIR /lychee
|
||||
|
||||
# Just copy the Cargo.toml and trigger a build so
|
||||
# that we compile our dependencies only.
|
||||
# This way we avoid layer cache invalidation
|
||||
# if our dependencies haven't changed,
|
||||
# resulting in faster builds.
|
||||
COPY Cargo.toml Cargo.toml
|
||||
RUN cargo build --release
|
||||
RUN rm src/*.rs
|
||||
|
||||
# Copy the source code and run the build again.
|
||||
# This should only compile lychee itself as the
|
||||
# dependencies were already built above.
|
||||
ADD . ./
|
||||
RUN rm ./target/release/deps/lychee*
|
||||
RUN cargo build --release
|
||||
|
||||
|
||||
# Our production image starts here, which uses
|
||||
# the files from the builder image above.
|
||||
FROM debian:buster-slim
|
||||
ARG APP=/usr/src/lychee
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y ca-certificates tzdata \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV TZ=Etc/UTC \
|
||||
APP_USER=lychee
|
||||
|
||||
RUN groupadd $APP_USER \
|
||||
&& useradd -g $APP_USER $APP_USER \
|
||||
&& mkdir -p ${APP}
|
||||
|
||||
COPY --from=builder /lychee/target/release/lychee ${APP}/lychee
|
||||
|
||||
RUN chown -R $APP_USER:$APP_USER ${APP}
|
||||
|
||||
USER $APP_USER
|
||||
WORKDIR ${APP}
|
||||
|
||||
ENTRYPOINT [ "./lychee" ]
|
||||
27
Makefile
Normal file
27
Makefile
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Needed SHELL since I'm using zsh
|
||||
SHELL := /bin/bash
|
||||
IMAGE_NAME := "lycheeverse/lychee"
|
||||
|
||||
.PHONY: help
|
||||
help: ## This help message
|
||||
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
|
||||
|
||||
.PHONY: docker-build
|
||||
docker-build: ## Build Docker image
|
||||
docker build -t $(IMAGE_NAME) .
|
||||
|
||||
.PHONY: docker-run
|
||||
docker-run: ## Run Docker image
|
||||
docker run $(IMAGE_NAME)
|
||||
|
||||
.PHONY: docker-push
|
||||
docker-push: ## Push image to Docker Hub
|
||||
docker push $(IMAGE_NAME)
|
||||
|
||||
.PHONY: build-local
|
||||
build: ## Build Rust code locally
|
||||
cargo build
|
||||
|
||||
.PHONY: run
|
||||
run: ## Run Rust code locally
|
||||
cargo run
|
||||
Loading…
Reference in a new issue