-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from bottlepay/docker-build
Add Docker build
- Loading branch information
Showing
2 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Create and publish a Docker image | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- master | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GHCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build the Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: "Debian: Extract metadata (tags, labels) for Docker" | ||
id: debian_meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=tag | ||
type=sha | ||
flavor: | | ||
latest=auto | ||
- name: "Debian: Push Docker image" | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.debian_meta.outputs.tags }} | ||
labels: ${{ steps.debian_meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
target: debian | ||
|
||
- name: "Alpine: Extract metadata (tags, labels) for Docker" | ||
id: alpine_meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=tag | ||
type=sha | ||
flavor: | | ||
suffix=-alpine | ||
- name: "Alpine: Push Docker image" | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.alpine_meta.outputs.tags }} | ||
labels: ${{ steps.alpine_meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
target: alpine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
FROM golang:1.18-alpine AS build | ||
|
||
ARG LEDGER_COMMIT="dirty" | ||
ARG LEDGER_TAG="dev" | ||
|
||
COPY . /go/src/github.com/bottlepay/lnmux | ||
|
||
RUN cd /go/src/github.com/bottlepay/lnmux \ | ||
&& GOOS=linux CGO_ENABLED=0 go install \ | ||
github.com/bottlepay/lnmux/cmd/... | ||
|
||
### Build an Alpine image | ||
FROM alpine:3.16 as alpine | ||
|
||
# Update CA certs | ||
RUN apk add --no-cache ca-certificates && rm -rf /var/cache/apk/* | ||
|
||
# Copy over app binary | ||
COPY --from=build /go/bin/lnmuxd /usr/bin/lnmuxd | ||
|
||
# Add a user | ||
RUN mkdir -p /app && adduser -D lnmux && chown -R lnmux /app | ||
USER lnmux | ||
|
||
WORKDIR /app/ | ||
|
||
CMD [ "/usr/bin/lnmuxd" ] | ||
|
||
### Build a Debian image | ||
FROM debian:bullseye-slim as debian | ||
|
||
# Update CA certs | ||
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy over app binary | ||
COPY --from=build /go/bin/lnmuxd /usr/bin/lnmuxd | ||
|
||
# Add a user | ||
RUN mkdir -p /app && adduser --disabled-login lnmux && chown -R lnmux /app | ||
USER lnmux | ||
|
||
WORKDIR /app | ||
|
||
CMD [ "/usr/bin/lnmuxd" ] |