Build Docker images and push to ghcr.io.

Also slim down the Dockerfile to only include Elvish.
This commit is contained in:
Qi Xiao 2024-02-29 10:24:11 +00:00
parent b39e9212cc
commit 2563b2316f
2 changed files with 34 additions and 6 deletions

32
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: docker
on:
push:
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,13 +1,9 @@
FROM golang:1.20-alpine as builder
FROM golang:1.22-alpine3.19 as builder
RUN apk add --no-cache --virtual build-deps make git
# Build Elvish
COPY . /go/src/src.elv.sh
RUN make -C /go/src/src.elv.sh get
FROM alpine:3.18
RUN adduser -D elf
RUN apk update && apk add tmux mandoc man-pages vim curl sqlite git
FROM alpine:3.19
COPY --from=builder /go/bin/elvish /bin/elvish
USER elf
WORKDIR /home/elf
CMD ["/bin/elvish"]