Browse Source

Add Dockerfiles and expand Makefile a bit

master v1.0.0-rc.0
Tyler Sommer 7 months ago
parent
commit
606091d506
Signed by: tyler-sommer GPG Key ID: C09C010500DBD008
6 changed files with 131 additions and 9 deletions
  1. +4
    -0
      .dockerignore
  2. +35
    -0
      Dockerfile
  3. +30
    -0
      Dockerfile.dist
  4. +42
    -8
      Makefile
  5. +19
    -0
      package.json
  6. +1
    -1
      plugin.go

+ 4
- 0
.dockerignore View File

@ -0,0 +1,4 @@
out/
vendor/
config.toml
Dockerfile

+ 35
- 0
Dockerfile View File

@ -0,0 +1,35 @@
FROM veonik/squirssi:build-amd64 AS build
FROM debian:buster-slim
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y ca-certificates curl gnupg && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn
COPY config.toml.dist /home/squirssi/.squirssi/config.toml
COPY package.json /home/squirssi/.squirssi/scripts/package.json
RUN cd /home/squirssi/.squirssi/scripts && \
yarn install
COPY --from=build /squirssi/out/squirssi_linux_amd64 /bin/squirssi
COPY --from=build /squirssi/out/*.so /squirssi/plugins/
RUN cd /squirssi/plugins && \
for f in `ls`; do ln -sf $f `echo $f | sed -e 's/_linux_amd64//'`; done
RUN useradd -d /home/squirssi squirssi && \
chown -R squirssi: /home/squirssi /squirssi
USER squirssi
WORKDIR /squirssi
CMD /bin/squirssi

+ 30
- 0
Dockerfile.dist View File

@ -0,0 +1,30 @@
FROM golang:buster AS build
ARG race
ARG goarch
ARG goarm
WORKDIR /squirssi
COPY . .
RUN go get -v ./...
RUN export SQUIRCY3_REVISION=$(cat go.mod | grep squircy3 | cut -d' ' -f2 | cut -d'-' -f3) && \
git clone https://github.com/veonik/squircy3 ../squircy3 && \
cd ../squircy3 && \
git checkout $SQUIRCY3_REVISION
RUN apt-get update && \
if [ "${goarch}" = "arm" ]; then \
apt-get install -y gcc-arm-linux-gnueabihf; \
elif [ "${goarch}" = "arm64" ]; then \
apt-get install -y gcc-aarch64-linux-gnu; \
fi;
RUN if [ "${goarch}" = "arm" ]; then \
CC=arm-linux-gnueabihf-gcc; \
elif [ "${goarch}" = "arm64" ]; then \
CC=aarch64-linux-gnu-gcc; \
fi; \
make clean dist RACE=${race} GOARCH=${goarch} GOARM=${goarm} CC=$CC

+ 42
- 8
Makefile View File

@ -1,19 +1,36 @@
# Makefile for squirssi, a proper IRC client.
# https://code.dopame.me/veonik/squirssi
SUBPACKAGES := colors
SUBPACKAGES := colors widget
# To build squircy3 plugins for squirssi, it's necessary to compile them all
# together along with squirssi to avoid dependency mismatches during the plugin
# loading process.
# This Makefile copies the plugin sources to within this Go module so that the
# Go tool will happily compile them into standalone shared libraries.
SQUIRCY3_ROOT ?= ../squircy3
PLUGINS := $(patsubst $(SQUIRCY3_ROOT)/plugins/%,%,$(wildcard $(SQUIRCY3_ROOT)/plugins/*))
SOURCES := $(wildcard *.go) $(wildcard cmd/*/*.go) $(wildcard $(patsubst %,%/*.go,$(SUBPACKAGES))) $(shell find vendor/ -type f -name '*.go' 2> /dev/null)
OUTPUT_BASE := out
PLUGIN_TARGETS := $(patsubst %,$(OUTPUT_BASE)/%.so,$(PLUGINS))
RACE ?= -race
TEST_ARGS ?= -count 1
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOARM ?= $(shell go env GOARM)
CC ?= $(shell go env CC)
PLUGIN_TARGETS := $(patsubst %,$(OUTPUT_BASE)/%.so,$(PLUGINS))
SQUIRSSI_TARGET := $(OUTPUT_BASE)/squirssi
SQUIRSSI_DIST := $(OUTPUT_BASE)/squirssi_$(GOOS)_$(GOARCH)$(GOARM)
PLUGIN_DIST := $(patsubst %,$(OUTPUT_BASE)/%_$(GOOS)_$(GOARCH)$(GOARM).so,$(PLUGINS))
DIST_TARGETS := $(SQUIRSSI_DIST) $(PLUGIN_DIST)
RACE ?= -race
TEST_ARGS ?= -count 1
SQUIRSSI_VERSION := $(if $(shell test -d .git && echo "1"),$(shell git describe --always --tags),SNAPSHOT)
SQUIRCY3_VERSION := $(if $(shell test -d $(SQUIRCY3_ROOT)/.git && echo "1"),$(shell cd $(SQUIRCY3_ROOT) && git describe --always --tags),SNAPSHOT)
.PHONY: all build generate run squirssi plugins clean
@ -24,12 +41,14 @@ clean:
build: squirssi
dist: $(DIST_TARGETS)
squirssi: $(SQUIRSSI_TARGET)
plugins: $(PLUGIN_TARGETS)
run: build
$(SQUIRSSI_TARGET) 2>> $(OUTPUT_BASE)/squirssi_errors.log
$(SQUIRSSI_TARGET)
test:
go test -tags netgo $(RACE) $(TEST_ARGS) ./...
@ -37,12 +56,27 @@ test:
$(OUTPUT_BASE)/plugins: $(OUTPUT_BASE)
cp -r $(SQUIRCY3_ROOT)/plugins $(OUTPUT_BASE)/plugins
$(SQUIRSSI_TARGET): $(SOURCES)
GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=$(CC) CGO_ENABLED=1 \
go build -tags netgo $(RACE) \
-ldflags "-s -w -X code.dopame.me/veonik/squirssi.Version=$(SQUIRSSI_VERSION)-SNAPSHOT -X main.Squircy3Version=$(SQUIRCY3_VERSION)-SNAPSHOT" \
-o $@ cmd/squirssi/*.go
$(SQUIRSSI_DIST): $(OUTPUT_BASE) $(SOURCES)
GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=$(CC) CGO_ENABLED=1 \
go build -tags netgo \
-ldflags "-s -w -X code.dopame.me/veonik/squirssi.Version=$(SQUIRSSI_VERSION) -X main.Squircy3Version=$(SQUIRCY3_VERSION)" \
-o $@ cmd/squirssi/*.go
.SECONDEXPANSION:
$(PLUGIN_TARGETS): $(OUTPUT_BASE)/%.so: $$(wildcard plugins/%/*) $(OUTPUT_BASE)/plugins $(SOURCES)
go build -tags netgo $(RACE) -o $@ -buildmode=plugin $(OUTPUT_BASE)/plugins/$*/*.go
GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=$(CC) CGO_ENABLED=1 \
go build -tags netgo $(RACE) -o $@ -buildmode=plugin $(OUTPUT_BASE)/plugins/$*/*.go
$(SQUIRSSI_TARGET): $(SOURCES)
go build -tags netgo $(RACE) -o $@ cmd/squirssi/*.go
.SECONDEXPANSION:
$(PLUGIN_DIST): $(OUTPUT_BASE)/%_$(GOOS)_$(GOARCH)$(GOARM).so: $$(wildcard plugins/%/*) $(OUTPUT_BASE)/plugins $(SOURCES)
GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=$(CC) CGO_ENABLED=1 \
go build -tags netgo -o $@ -buildmode=plugin $(OUTPUT_BASE)/plugins/$*/*.go
$(OUTPUT_BASE):
mkdir -p $(OUTPUT_BASE)


+ 19
- 0
package.json View File

@ -0,0 +1,19 @@
{
"name": "squirssi-scripts",
"version": "0.0.1",
"license": "MIT",
"private": true,
"dependencies": {
"@babel/standalone": "7.5.5",
"assert": "2.0.0",
"assert-polyfill": "0.0.0",
"buffer": "5.2.1",
"core-js-bundle": "3.1.4",
"process": "0.11.10",
"regenerator-runtime": "0.13.3",
"regenerator-transform": "0.14.1"
},
"resolutions": {
"util": "0.12.1"
}
}

+ 1
- 1
plugin.go View File

@ -32,7 +32,7 @@ func Initialize(m *plugin.Manager) (plugin.Plugin, error) {
if err != nil {
return nil, errors.Wrapf(err, "%s: missing required dependency (irc)", pluginName)
}
ircp.SetVersionString(fmt.Sprintf("squirssi v%s", Version))
ircp.SetVersionString(fmt.Sprintf("squirssi %s", Version))
srv, err := NewServer(ev, ircp)
if err != nil {
return nil, errors.Wrapf(err, "%s: failed to initialize Server", pluginName)


Loading…
Cancel
Save