Skip to content

Commit

Permalink
Merge pull request #38 from bottlepay/docker-build
Browse files Browse the repository at this point in the history
Add Docker build
  • Loading branch information
joostjager authored Jul 25, 2022
2 parents f6beb2e + f9f2c57 commit 1d601ba
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/docker-build.yml
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
44 changes: 44 additions & 0 deletions Dockerfile
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" ]

0 comments on commit 1d601ba

Please sign in to comment.