mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-24 07:48:19 +00:00
Add a Dockerfile and push to prologic/salty-chat as well as a Drone CI config for CI/CD
This commit is contained in:
parent
aabd291efc
commit
646ab22372
18
.dockerfiles/entrypoint.sh
Executable file
18
.dockerfiles/entrypoint.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -n "${PUID}" ] && usermod -u "${PUID}" salty
|
||||
[ -n "${PGID}" ] && groupmod -g "${PGID}" salty
|
||||
|
||||
printf "Configuring salty-chat ..."
|
||||
#[ -z "${DATA}" ] && DATA="/data"
|
||||
#[ -z "${STORE}" ] && STORE="bitcask:///data/yarn.db"
|
||||
#[ -z "${OPEN_REGISTRATIONS}" ] && OPEN_REGISTRATIONS=true
|
||||
#[ -z "${OPEN_PROFILES}" ] && OPEN_PROFILES=true
|
||||
#[ -z "${COOKIE_SECRET}" ] && COOKIE_SECRET="$(random_string)"
|
||||
#[ -z "${MAGICLINK_SECRET}" ] && MAGICLINK_SECRET="$(random_string)"
|
||||
#[ -z "${API_SIGNING_KEY}" ] && API_SIGNING_KEY="$(random_string)"
|
||||
|
||||
export DATA STORE OPEN_REGISTRATIONS OPEN_PROFILES COOKIE_SECRET MAGICLINK_SECRET API_SIGNING_KEY
|
||||
|
||||
printf "Switching UID=%s and GID=%s\n" "${PUID}" "${PGID}"
|
||||
exec su-exec salty:ysalty "$@"
|
49
.drone.yml
Normal file
49
.drone.yml
Normal file
@ -0,0 +1,49 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: build-and-test
|
||||
image: r.mills.io/prologic/golang-alpine:latest
|
||||
commands:
|
||||
- make deps
|
||||
- make build
|
||||
- make test
|
||||
|
||||
- name: build-image-push
|
||||
image: plugins/kaniko
|
||||
settings:
|
||||
repo: prologic/salty-chat
|
||||
tags: latest
|
||||
build_args:
|
||||
- VERSION=edge
|
||||
- COMMIT=${DRONE_COMMIT_SHA:0:8}
|
||||
username:
|
||||
from_secret: dockerhub_username
|
||||
password:
|
||||
from_secret: dockerhub_password
|
||||
depends_on:
|
||||
- build-and-test
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
|
||||
- name: notify-irc
|
||||
image: plugins/webhook
|
||||
settings:
|
||||
urls:
|
||||
- https://msgbus.mills.io/ci.mills.io
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- tag
|
||||
- push
|
||||
- pull_request
|
59
Dockerfile
Normal file
59
Dockerfile
Normal file
@ -0,0 +1,59 @@
|
||||
# Build
|
||||
FROM golang:alpine AS build
|
||||
|
||||
RUN apk add --no-cache -U build-base git make
|
||||
|
||||
RUN mkdir -p /src
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
# Copy Makefile
|
||||
COPY Makefile ./
|
||||
|
||||
# Install deps
|
||||
RUN make deps
|
||||
|
||||
# Copy go.mod and go.sum and install and cache dependencies
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
|
||||
# Copy sources
|
||||
COPY *.go ./
|
||||
COPY ./cmd/salty-chat/*.go ./cmd/salty-chat/
|
||||
|
||||
# Version/Commit (there there is no .git in Docker build context)
|
||||
# NOTE: This is fairly low down in the Dockerfile instructions so
|
||||
# we don't break the Docker build cache just be changing
|
||||
# unrelated files that actually haven't changed but caused the
|
||||
# COMMIT value to change.
|
||||
ARG VERSION="0.0.0"
|
||||
ARG COMMIT="HEAD"
|
||||
|
||||
# Build binary
|
||||
RUN make build VERSION=$VERSION COMMIT=$COMMIT
|
||||
|
||||
# Runtime
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk --no-cache -U add su-exec shadow ca-certificates tzdata
|
||||
|
||||
ENV PUID=1000
|
||||
ENV PGID=1000
|
||||
|
||||
RUN addgroup -g "${PGID}" salty && \
|
||||
adduser -D -H -G salty -h /var/empty -u "${PUID}" salty && \
|
||||
mkdir -p /data && chown -R salty:salty /data
|
||||
|
||||
VOLUME /data
|
||||
|
||||
WORKDIR /
|
||||
|
||||
# force cgo resolver
|
||||
ENV GODEBUG=netdns=cgo
|
||||
|
||||
COPY --from=build /src/salty-chat /usr/local/bin/salty-chat
|
||||
|
||||
COPY .dockerfiles/entrypoint.sh /init
|
||||
|
||||
ENTRYPOINT ["/init"]
|
||||
CMD ["salty-chat"]
|
2
Makefile
2
Makefile
@ -10,7 +10,7 @@ GOVER=$(shell go version | grep -o -E 'go1\.17\.[0-9]+')
|
||||
|
||||
DESTDIR=/usr/local/bin
|
||||
|
||||
ifeq ($(BRANCH), main)
|
||||
ifeq ($(BRANCH), master)
|
||||
IMAGE := prologic/salty-chat
|
||||
TAG := latest
|
||||
else
|
||||
|
@ -1,5 +1,7 @@
|
||||
# Salty IM
|
||||
|
||||
[![Build Status](https://ci.mills.io/api/badges/prologic/saltyim/status.svg)](https://ci.mills.io/prologic/saltyim)
|
||||
|
||||
## Quick Start
|
||||
|
||||
```#!sh
|
||||
|
Loading…
Reference in New Issue
Block a user