-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
98 additions
and
0 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,4 @@ | ||
.git | ||
target | ||
assets | ||
fixtures |
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,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/[email protected] | ||
with: | ||
name: lycheeverse/lychee | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
snapshot: true | ||
tag_semver: true |
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,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" ] |
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,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 |