Skip to content
Merged
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
32 changes: 26 additions & 6 deletions .github/actions/nightly-release/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ inputs:
description: Docker hub password
required: true

name:
description: The name of the build
default: nightly
required: false

workdir:
description: The working directory for actions requiring it
required: true
Expand All @@ -21,16 +26,31 @@ runs:
shell: bash
run: docker login -u "${{ inputs.hub_username }}" -p "${{ inputs.hub_password }}"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: stable

- name: Generate build metadata
shell: sh
run: |
echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
echo "GIT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "BUILD_NAME=$(echo ${{ inputs.name }} | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9.-]/-/g')" >> $GITHUB_ENV

- name: Build and push Docker images
# Use commit hash here to avoid a re-tagging attack, as this is a third-party action
# Commit 9ed2f89a662bf1735a48bc8557fd212fa902bebf = tag v6.1.0
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf
uses: docker/build-push-action@v6
with:
workdir: "${{ inputs.workdir }}"
version: ~> v2
args: release --skip=announce,validate --config .goreleaser-nightly.yml
context: "${{ inputs.workdir }}"
file: "${{ inputs.workdir }}/docker/Dockerfile.nightly"
build-args: |
VERSION=nightly-${{ env.BUILD_DATE }}
GIT_COMMIT=${{ env.GIT_COMMIT }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
synadia/nats-server:${{ env.BUILD_NAME }}
synadia/nats-server:${{ env.BUILD_NAME }}-${{ env.BUILD_DATE }}
1 change: 1 addition & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:

- uses: ./src/github.com/nats-io/nats-server/.github/actions/nightly-release
with:
name: ${{ inputs.target || 'nightly' }}
workdir: src/github.com/nats-io/nats-server
hub_username: "${{ secrets.DOCKER_USERNAME }}"
hub_password: "${{ secrets.DOCKER_PASSWORD }}"
40 changes: 0 additions & 40 deletions .goreleaser-nightly.yml

This file was deleted.

36 changes: 25 additions & 11 deletions docker/Dockerfile.nightly
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
FROM golang:alpine AS builder

ARG VERSION="nightly"
ARG GIT_COMMIT
ARG TARGETOS
ARG TARGETARCH

RUN apk add --update git
RUN mkdir -p src/github.com/nats-io && \
cd src/github.com/nats-io/ && \
git clone https://github.com/nats-io/natscli.git && \
cd natscli/nats && \
go build -ldflags "-w -X main.version=${VERSION}" -o /nats
ENV GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
GO111MODULE=on \
CGO_ENABLED=0

RUN go install github.com/nats-io/nsc/v2@latest
RUN apk add --no-cache git ca-certificates
RUN mkdir -p /src/nats-server /src/natscli /src/nsc

FROM alpine:latest
COPY . /src/nats-server
RUN git clone --depth 1 https://github.com/nats-io/natscli /src/natscli
RUN git clone --depth 1 https://github.com/nats-io/nsc /src/nsc

WORKDIR /src/nats-server
RUN go install -v -trimpath -ldflags "-w -X server.serverVersion=${VERSION},server.gitCommit=${GIT_COMMIT}" .

WORKDIR /src/natscli
RUN go install -v -trimpath -ldflags "-w -X main.version=${VERSION}" ./nats

RUN apk add --update ca-certificates && mkdir -p /nats/bin && mkdir /nats/conf
WORKDIR /src/nsc
RUN go install -v -trimpath .

FROM alpine:latest

COPY docker/nats-server.conf /nats/conf/nats-server.conf
COPY nats-server /bin/nats-server
COPY --from=builder /nats /bin/nats
COPY --from=builder /go/bin/nats-server /bin/nats-server
COPY --from=builder /go/bin/nats /bin/nats
COPY --from=builder /go/bin/nsc /bin/nsc
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

EXPOSE 4222 8222 6222 5222

Expand Down
Loading