Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/docker-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Docker-Dev

on:
push:
branches:
- dev
paths:
- ".github/workflows/docker-dev.yml"
- "docker/Dockerfile"
- "src/**"
- "Cargo.toml"

env:
package_name: simple-http-server
GHCR_SLUG: ghcr.io/${{ github.repository }}

jobs:
build:
strategy:
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
runner: ubuntu-24.04
tag: dev-amd64
- arch: arm64
runner: ubuntu-24.04-arm
tag: dev-arm64
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v4

- name: Login to GitHub Container Registry (ghcr.io)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.GHCR_SLUG }}
tags: ${{ matrix.tag }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
platforms: linux/${{ matrix.arch }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.GHCR_SLUG }}:${{ matrix.tag }}

manifest:
needs: build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push multi-arch manifest
run: |
docker manifest create ${{ env.GHCR_SLUG }}:dev \
--amend ${{ env.GHCR_SLUG }}:dev-amd64 \
--amend ${{ env.GHCR_SLUG }}:dev-arm64
docker manifest push ${{ env.GHCR_SLUG }}:dev
shell: bash

- uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: ${{ env.package_name }}
package-type: 'container'
min-versions-to-keep: 2
delete-only-untagged-versions: 'true'
86 changes: 86 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Docker

on:
push:
branches:
- main
- master
paths:
- ".github/workflows/docker.yml"
- "docker/Dockerfile"
- "src/**"
- "Cargo.toml"

env:
package_name: simple-http-server
GHCR_SLUG: ghcr.io/${{ github.repository }}

jobs:
build:
strategy:
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
runner: ubuntu-24.04
tag: amd64
- arch: arm64
runner: ubuntu-24.04-arm
tag: arm64
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v4

- name: Login to GitHub Container Registry (ghcr.io)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.GHCR_SLUG }}
tags: ${{ matrix.tag }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
platforms: linux/${{ matrix.arch }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.GHCR_SLUG }}:${{ matrix.tag }}

manifest:
needs: build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push multi-arch manifest
run: |
docker manifest create ${{ env.GHCR_SLUG }}:latest \
--amend ${{ env.GHCR_SLUG }}:amd64 \
--amend ${{ env.GHCR_SLUG }}:arm64
docker manifest push ${{ env.GHCR_SLUG }}:latest
shell: bash

- uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: ${{ env.package_name }}
package-type: 'container'
min-versions-to-keep: 2
delete-only-untagged-versions: 'true'
26 changes: 26 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file is copied from: https://github.com/k4yt3x/simple-http-server/blob/master/Dockerfile
# LICENS: BSD 2-Clause "Simplified" License
# please see https://github.com/k4yt3x/simple-http-server/blob/master/LICENSE for more details

FROM rust:1.88-alpine AS builder
WORKDIR /build
COPY . .
RUN <<EOF
apk add --no-cache --virtual .build-deps git make musl-dev openssl-dev perl pkgconfig gcc
RUSTFLAGS='-C link-arg=-s' cargo build \
--features only-openssl \
--no-default-features \
--release
EOF

FROM gcr.io/distroless/static:nonroot
LABEL maintainer="thewawar <thewawar@gmail.com>" \
org.opencontainers.image.source="https://github.com/TheWaWaR/simple-http-server" \
org.opencontainers.image.description="A minimal distroless container image for TheWaWaR/simple-http-server"
COPY --from=builder \
/build/target/release/simple-http-server \
/usr/local/bin/simple-http-server
USER nonroot:nonroot
WORKDIR /var/www/html
EXPOSE 8000
ENTRYPOINT ["simple-http-server"]