Skip to content

Commit ae217e7

Browse files
committed
Refined Dockerfile 12Mb
1 parent 9c27b35 commit ae217e7

File tree

2 files changed

+44
-15
lines changed

2 files changed

+44
-15
lines changed

.github/workflows/build-docker.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build + Publish Docker Image 🐳
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
env:
10+
IMAGE_NAME: adguardian
11+
DOCKER_USER: ${{ github.repository_owner }}
12+
REGISTRY: ghcr.io
13+
14+
jobs:
15+
docker:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v1
24+
25+
- name: Login to GitHub Container Registry
26+
uses: docker/login-action@v1
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Build and push Docker images
33+
uses: docker/build-push-action@v2
34+
with:
35+
context: .
36+
file: ./Dockerfile
37+
push: true
38+
platforms: linux/amd64,linux/arm64,linux/arm/v7
39+
tags: |
40+
${{ env.REGISTRY }}/${{ env.DOCKER_USER }}/${{ env.IMAGE_NAME }}:latest

Dockerfile

+4-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
# syntax=docker/dockerfile:1.2
22

3+
# Build application - Copy assets, install deps and compile binary
34
FROM --platform=$BUILDPLATFORM rust:1.69.0-alpine AS builder
4-
5-
# Adding necessary packages
6-
RUN apk update
7-
RUN apk add pkgconfig openssl openssl-dev musl-dev
8-
9-
# Set working directory in container; make directory if not exists
10-
RUN mkdir -p /usr/src/adguardian
5+
RUN apk add --no-cache pkgconfig openssl openssl-dev musl-dev
116
WORKDIR /usr/src/adguardian
12-
13-
# Copy all files from local computer to container
14-
COPY Cargo.toml .
15-
COPY Cargo.lock .
16-
COPY src src
17-
18-
# Build release application
7+
COPY . .
198
RUN cargo build --release
209

21-
10+
# Run application - Using lightweight base, execute the binary
2211
FROM scratch
2312
COPY --from=builder /usr/src/adguardian/target/release/adguardian /
2413
ENTRYPOINT ["/adguardian"]

0 commit comments

Comments
 (0)