Browse Source

Merge pull request #7 from oragono/master+multistage

Master+multistage
pull/9/head
Daniel Oaks 5 years ago
parent
commit
04127c363b
No account linked to committer's email address
2 changed files with 82 additions and 16 deletions
  1. 55
    8
      Dockerfile
  2. 27
    8
      run.sh

+ 55
- 8
Dockerfile View File

@@ -1,17 +1,64 @@
1
-FROM golang:rc
1
+## build Oragono
2
+FROM golang:rc-alpine AS build-env
2 3
 
3
-EXPOSE 6667/tcp 6697/tcp
4
+RUN apk add --no-cache git
5
+RUN apk add --no-cache make
6
+RUN apk add --no-cache curl
7
+
8
+# install goreleaser
9
+RUN mkdir -p /go/src/github.com/goreleaser
10
+WORKDIR /go/src/github.com/goreleaser
4 11
 
5
-RUN apt-get install -y git
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
6 16
 
17
+# get oragono
7 18
 RUN mkdir -p /go/src/github.com/oragono
8 19
 WORKDIR /go/src/github.com/oragono
9 20
 
10
-RUN git clone https://github.com/oragono/oragono.git
21
+RUN git clone --recurse-submodules https://github.com/oragono/oragono.git
11 22
 WORKDIR /go/src/github.com/oragono/oragono
12
-RUN git submodule update --init
13
-RUN go build oragono.go
14 23
 
15
-COPY run.sh /go/src/github.com/oragono/oragono
24
+# compile
25
+RUN make build
26
+
27
+
28
+
29
+## run Oragono
30
+FROM alpine:3.9
31
+
32
+# metadata
33
+LABEL maintainer="daniel@danieloaks.net"
34
+
35
+# install latest updates and configure alpine
36
+RUN apk update
37
+RUN apk upgrade
38
+RUN mkdir /lib/modules
39
+
40
+# standard ports listened on
41
+EXPOSE 6667/tcp 6697/tcp
42
+
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
53
+WORKDIR /ircd
54
+
55
+# default motd
56
+COPY --from=build-env /go/src/github.com/oragono/oragono/oragono.motd /ircd/oragono.motd
57
+
58
+# launch
59
+CMD /ircd-bin/run.sh
16 60
 
17
-CMD ["./run.sh"]
61
+# # uncomment to debug
62
+# RUN apk add --no-cache bash
63
+# RUN apk add --no-cache vim
64
+# CMD /bin/bash

+ 27
- 8
run.sh View File

@@ -1,17 +1,36 @@
1 1
 #!/bin/sh
2 2
 
3
-set -e
3
+# start in right dir
4
+cd /ircd
4 5
 
5
-if [ ! -f ./ircd.yaml ]; then
6
-  cp oragono.yaml ircd.yaml
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
+
10
+    # change default oper passwd
11
+    OPERPASS=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c20)
12
+    echo "Oper username:password is dan:$OPERPASS"
13
+    ENCRYPTEDPASS=$(echo "$OPERPASS" | /ircd-bin/oragono genpasswd)
14
+    ORIGINALPASS='\$2a\$04\$LiytCxaY0lI.guDj2pBN4eLRD5cdM2OLDwqmGAgB6M2OPirbF5Jcu'
15
+
16
+    awk "{gsub(/password: \\\"$ORIGINALPASS\\\"/,\"password: \\\"$ENCRYPTEDPASS\\\"\")}1" /tmp/ircd.yaml > /tmp/ircd2.yaml
17
+
18
+    unset OPERPASS
19
+    unset ENCRYPTEDPASS
20
+    unset ORIGINALPASS
21
+
22
+    mv /tmp/ircd2.yaml /ircd/ircd.yaml
7 23
 fi
8 24
 
9
-if [ ! -f ircd.db ]; then
10
-  ./oragono initdb
25
+# make db
26
+if [ ! -f "/ircd/ircd.db" ]; then
27
+    /ircd-bin/oragono initdb
11 28
 fi
12 29
 
13
-if [ ! -f tls.crt ]; then
14
-  ./oragono mkcerts
30
+# make self-signed certs
31
+if [ ! -f "/ircd/tls.key" ]; then
32
+    /ircd-bin/oragono mkcerts
15 33
 fi
16 34
 
17
-exec ./oragono run
35
+# run!
36
+/ircd-bin/oragono run

Loading…
Cancel
Save