-
Notifications
You must be signed in to change notification settings - Fork 47
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
2 changed files
with
44 additions
and
15 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,40 @@ | ||
name: Build + Publish Docker Image 🐳 | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
IMAGE_NAME: adguardian | ||
DOCKER_USER: ${{ github.repository_owner }} | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker images | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.DOCKER_USER }}/${{ env.IMAGE_NAME }}:latest |
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,24 +1,13 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
|
||
# Build application - Copy assets, install deps and compile binary | ||
FROM --platform=$BUILDPLATFORM rust:1.69.0-alpine AS builder | ||
|
||
# Adding necessary packages | ||
RUN apk update | ||
RUN apk add pkgconfig openssl openssl-dev musl-dev | ||
|
||
# Set working directory in container; make directory if not exists | ||
RUN mkdir -p /usr/src/adguardian | ||
RUN apk add --no-cache pkgconfig openssl openssl-dev musl-dev | ||
WORKDIR /usr/src/adguardian | ||
|
||
# Copy all files from local computer to container | ||
COPY Cargo.toml . | ||
COPY Cargo.lock . | ||
COPY src src | ||
|
||
# Build release application | ||
COPY . . | ||
RUN cargo build --release | ||
|
||
|
||
# Run application - Using lightweight base, execute the binary | ||
FROM scratch | ||
COPY --from=builder /usr/src/adguardian/target/release/adguardian / | ||
ENTRYPOINT ["/adguardian"] |