Skip to content

Commit

Permalink
Refined Dockerfile 12Mb
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed May 28, 2023
1 parent 9c27b35 commit ae217e7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 15 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build-docker.yml
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
19 changes: 4 additions & 15 deletions Dockerfile
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"]

0 comments on commit ae217e7

Please sign in to comment.