Skip to content

Commit 8910ef7

Browse files
committed
chore: Add nightly build docker image
1 parent c6712b7 commit 8910ef7

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build Nushell Nightly Image @ Alpine
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- docker/Dockerfile
9+
schedule:
10+
- cron: '0 5 * * *' # run at 05:00 AM UTC
11+
workflow_dispatch:
12+
13+
jobs:
14+
build-and-push-Nu:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
steps:
20+
- name: Checkout Code
21+
uses: actions/checkout@v4
22+
with:
23+
ref: nightly
24+
25+
- name: Set up Nushell
26+
uses: hustcer/setup-nu@v3
27+
with:
28+
check-latest: true
29+
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v3
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Login to GitHub Container Registry
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ghcr.io
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: "Set tag & labels for ${{ github.ref }}"
44+
shell: nu {0}
45+
run: |
46+
let queryApi = http get https://api.github.com/repos/nushell/nightly/releases
47+
| sort-by -r created_at | get 0.url
48+
$'NU_VERSION=nightly(char nl)' o>> $env.GITHUB_ENV
49+
$'RELEASE_QUERY_API=($queryApi)(char nl)' o>> $env.GITHUB_ENV
50+
$'BUILD_REF=(git rev-parse --short HEAD)(char nl)' o>> $env.GITHUB_ENV
51+
$'BUILD_DATE=(date now | format date %Y-%m-%dT%H:%M:%SZ)(char nl)' o>> $env.GITHUB_ENV
52+
53+
- name: Build and Push Alpine Image
54+
uses: docker/build-push-action@v6
55+
with:
56+
push: true
57+
context: ./docker
58+
file: ./docker/Dockerfile
59+
platforms: linux/amd64,linux/arm64,linux/arm/v7
60+
build-args: |
61+
BUILD_REF=${{ env.BUILD_REF }}
62+
BUILD_DATE=${{ env.BUILD_DATE }}
63+
NU_VERSION=${{ env.NU_VERSION }}
64+
RELEASE_QUERY_API=${{ env.RELEASE_QUERY_API }}
65+
tags: |
66+
ghcr.io/nushell/nushell:latest
67+
ghcr.io/nushell/nushell:latest-alpine
68+
ghcr.io/nushell/nushell:${{ env.NU_VERSION }}
69+
ghcr.io/nushell/nushell:${{ env.NU_VERSION }}-alpine

docker/Dockerfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# syntax=docker/dockerfile:latest
2+
3+
# Git: git version 2.30.2
4+
# /etc/os-release: Alpine Linux v3.20
5+
# Kernel: Linux ca3abedc4fb1 5.17.15-76051715-generic #202206141358~1655919116~22.04~1db9e34 SMP PREEMPT Wed Jun 22 19 x86_64 Linux
6+
# Build cmd: docker build --no-cache . -t nushell:latest
7+
# Other tags: nushell:latest-alpine, nushell
8+
FROM alpine
9+
10+
ARG TARGETARCH
11+
ARG ARCH=${TARGETARCH/arm64/aarch64}
12+
ARG ARCH=${ARCH/arm/armv7}
13+
ARG ARCH=${ARCH/amd64/x86_64}
14+
15+
ARG BUILD_REF
16+
ARG BUILD_DATE
17+
ARG RELEASE_QUERY_API="https://api.github.com/repos/nushell/nushell/releases/latest"
18+
19+
LABEL maintainer="The Nushell Project Developers" \
20+
org.opencontainers.image.licenses="MIT" \
21+
org.opencontainers.image.title="Nushell" \
22+
org.opencontainers.image.created=$BUILD_DATE \
23+
org.opencontainers.image.revision=$BUILD_REF \
24+
org.opencontainers.image.authors="The Nushell Project Developers" \
25+
org.opencontainers.image.vendor="Nushell Project" \
26+
org.opencontainers.image.description="A new type of shell" \
27+
org.opencontainers.image.source="https://github.com/nushell/nushell" \
28+
org.opencontainers.image.documentation="https://www.nushell.sh/book/"
29+
30+
RUN echo '/usr/bin/nu' >> /etc/shells \
31+
&& adduser -D -s /usr/bin/nu nushell \
32+
&& mkdir -p /home/nushell/.config/nushell/ \
33+
&& cd /tmp \
34+
&& wget -qO - ${RELEASE_QUERY_API} \
35+
| grep browser_download_url \
36+
| cut -d '"' -f 4 \
37+
| grep ${ARCH}-unknown-linux-musl \
38+
| xargs -I{} wget {} \
39+
&& mkdir nu-latest && tar xvf nu-*.tar.gz --directory=nu-latest \
40+
&& cp -aR nu-latest/**/* /usr/bin/ \
41+
# Setup default config file for nushell
42+
&& cd /home/nushell/.config/nushell \
43+
&& chmod +x /usr/bin/nu \
44+
&& chown -R nushell:nushell /home/nushell/.config/nushell \
45+
# Reset Nushell config to default
46+
&& su -c 'config reset -w' nushell \
47+
&& ls /usr/bin/nu_plugin* \
48+
| xargs -I{} su -c 'plugin add {}' nushell \
49+
&& rm -rf /tmp/*
50+
51+
USER nushell
52+
53+
WORKDIR /home/nushell
54+
55+
ENTRYPOINT ["nu"]

0 commit comments

Comments
 (0)