Browse Source

Use volumes for data files, build using goreleaser

pull/7/head
Daniel Oaks 5 years ago
parent
commit
1e1ab11b47
2 changed files with 63 additions and 19 deletions
  1. 41
    19
      Dockerfile
  2. 22
    0
      run.sh

+ 41
- 19
Dockerfile View File

@@ -1,20 +1,36 @@
1
-# build Oragono
2
-FROM golang:rc AS build-env
1
+## build Oragono
2
+FROM golang:rc-alpine AS build-env
3 3
 
4
-RUN apt-get install -y git
4
+RUN apk add --no-cache git
5
+RUN apk add --no-cache make
6
+RUN apk add --no-cache curl
5 7
 
8
+# install goreleaser
9
+RUN mkdir -p /go/src/github.com/goreleaser
10
+WORKDIR /go/src/github.com/goreleaser
11
+
12
+RUN git clone https://github.com/goreleaser/goreleaser.git
13
+WORKDIR /go/src/github.com/goreleaser/goreleaser
14
+RUN make setup build
15
+RUN cp ./goreleaser /usr/bin
16
+
17
+# get oragono
6 18
 RUN mkdir -p /go/src/github.com/oragono
7 19
 WORKDIR /go/src/github.com/oragono
8 20
 
9
-RUN git clone https://github.com/oragono/oragono.git
21
+RUN git clone --recurse-submodules https://github.com/oragono/oragono.git
10 22
 WORKDIR /go/src/github.com/oragono/oragono
11
-RUN git submodule update --init
12 23
 
13 24
 # compile
14
-RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s" -o build/docker/oragono oragono.go
25
+RUN make build
26
+
15 27
 
16
-# run in a lightweight distro
17
-FROM alpine
28
+
29
+## run Oragono
30
+FROM alpine:3.9
31
+
32
+# metadata
33
+LABEL maintainer="daniel@danieloaks.net"
18 34
 
19 35
 # install latest updates and configure alpine
20 36
 RUN apk update
@@ -24,19 +40,25 @@ RUN mkdir /lib/modules
24 40
 # standard ports listened on
25 41
 EXPOSE 6667/tcp 6697/tcp
26 42
 
27
-# prep and copy oragono from build environment
28
-RUN mkdir -p /ircd
43
+# oragono itself
44
+RUN mkdir -p /ircd-bin
45
+COPY --from=build-env /go/src/github.com/oragono/oragono/dist/linux_arm64/oragono /ircd-bin
46
+COPY --from=build-env /go/src/github.com/oragono/oragono/languages /ircd-bin/languages/
47
+COPY --from=build-env /go/src/github.com/oragono/oragono/oragono.yaml /ircd-bin/oragono.yaml
48
+COPY run.sh /ircd-bin/run.sh
49
+RUN chmod +x /ircd-bin/run.sh
50
+
51
+# running volume holding config file, db, certs
52
+VOLUME /ircd
29 53
 WORKDIR /ircd
30
-COPY --from=build-env /go/src/github.com/oragono/oragono/build/docker/ .
31
-COPY --from=build-env /go/src/github.com/oragono/oragono/oragono.yaml ./ircd.yaml
32 54
 
33
-# init
34
-RUN ./oragono initdb
35
-RUN ./oragono mkcerts
55
+# default motd
56
+COPY --from=build-env /go/src/github.com/oragono/oragono/oragono.motd /ircd/oragono.motd
36 57
 
37 58
 # launch
38
-CMD ./oragono run
59
+CMD /ircd-bin/run.sh
39 60
 
40
-# uncomment to debug
41
-#RUN apk add bash nano
42
-#CMD /bin/bash
61
+# # uncomment to debug
62
+# RUN apk add --no-cache bash
63
+# RUN apk add --no-cache vim
64
+# CMD /bin/bash

+ 22
- 0
run.sh View File

@@ -0,0 +1,22 @@
1
+#/bin/sh
2
+
3
+# start in right dir
4
+cd /ircd
5
+
6
+# make config file
7
+if [ ! -f "/ircd/ircd.yaml" ]; then
8
+    awk '{gsub(/path: languages/,"path: /ircd-bin/languages")}1' /ircd-bin/oragono.yaml > /tmp/ircd.yaml
9
+    mv /tmp/ircd.yaml /ircd/ircd.yaml
10
+fi
11
+
12
+# make db and certs
13
+if [ ! -f "/ircd/ircd.db" ]; then
14
+    /ircd-bin/oragono initdb
15
+fi
16
+
17
+if [ ! -f "/ircd/tls.key" ]; then
18
+    /ircd-bin/oragono mkcerts
19
+fi
20
+
21
+# run!
22
+/ircd-bin/oragono run

Loading…
Cancel
Save