Skip to content

Commit

Permalink
Merge branch '0.7.x' of github.com:chennqqi/godnslog into 0.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
chennqqi committed Aug 9, 2021
2 parents ec44647 + d1198a0 commit 6f0660a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 53 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN yarn config set registry https://registry.npm.taobao.org && yarn install
RUN yarn build

# build backend
FROM golang:1.16.4 as backend-builder
FROM golang:1.16.4-alpine as backend-builder

RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.12/main" > /etc/apk/repositories
#RUN apk add build-base git musl-dev
Expand All @@ -29,10 +29,12 @@ RUN mkdir -p /app
COPY --from=backend-builder /go/bin/godnslog /app/godnslog
COPY --from=frontend-builder /app/dist /app/dist

RUN addgroup -S app && \
adduser app -S -G app -h /app && \
chown -R app:app /app && \
setcap cap_net_bind_service=eip /app/godnslog
ARG UID=1000
ARG GID=1000

RUN addgroup -g $GID -S app && adduser -u $UID -S -g app app && \
chown -R app:app /app && \
setcap cap_net_bind_service=eip /app/godnslog

WORKDIR /app
USER app
Expand Down
18 changes: 10 additions & 8 deletions DockerfileCN
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ COPY frontend /app
RUN yarn config set registry https://registry.npm.taobao.org && yarn install
RUN yarn build

FROM golang:1.16.4 as backend-builder
FROM golang:1.16.4-alpine as backend-builder

RUN go env -w GOPROXY=https://goproxy.cn
#RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.12/main" > /etc/apk/repositories
#RUN apk add build-base git musl-dev
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.12/main" > /etc/apk/repositories
RUN apk add build-base git musl-dev

COPY models /src/godnslog/models
COPY server /src/godnslog/server
COPY cache /src/godnslog/cache
COPY *.go go.mod /src/godnslog/
WORKDIR /src/godnslog
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/godnslog
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -mod=mod -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/godnslog

FROM alpine:3.13.5

Expand All @@ -31,10 +31,12 @@ RUN mkdir -p /app
COPY --from=backend-builder /go/bin/godnslog /app/godnslog
COPY --from=frontend-builder /app/dist /app/dist

RUN addgroup -S app && \
adduser app -S -G app -h /app && \
chown -R app:app /app && \
setcap cap_net_bind_service=eip /app/godnslog
ARG UID=1000
ARG GID=1000

RUN addgroup -g $GID -S app && adduser -u $UID -S -g app app && \
chown -R app:app /app && \
setcap cap_net_bind_service=eip /app/godnslog

WORKDIR /app
USER app
Expand Down
39 changes: 17 additions & 22 deletions docker-compose-mysql.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
version: "3.6" #docker version>=18.02.0+
version: "3.3" #docker version>=18.02.0+

services:
godnslog:
container_name: godnslog
depends_on:
- db
image: sort/godnslog
command: serve -domain yourdomain.com -4 x.x.x.x -dsn 'mysql://'
container_name: godnslog
command: serve -domain yourdomain.com -4 x.x.x.x -driver mysql -dsn 'godnslog:godnslog123@tcp(db:3306)/godnslog?charset=utf8'
ports:
- "127.0.0.1:10080:8080" # reverseProxy
- "8080:8080" # reverseProxy
- "53:53/udp"
environment:
- GIN_MODE=release
restart: always
depends_on:
- db
networks:
- overlay

db:
image: mysql
image: mysql:5.7
container_name: godnslog-mysql
restart: always
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_USER:
MYSQL_PASSWORD:
MYSQL_DATABASE:
networks:
- overlay
MYSQL_ROOT_PASSWORD: godnslogPASS
MYSQL_USER: godnslog
MYSQL_PASSWORD: godnslog123
MYSQL_DATABASE: godnslog
MYSQL_ROOT_HOST: "0.0.0.0"
volumes:
- db-data:/var/lib/mysql/data
- godnslog-mysql-data:/var/lib/mysql
#- ./mysql:/docker-entrypoint-initdb.d/

networks:
overlay:

volumes:
godnslog-data:
godnslog-mysql-data:
27 changes: 27 additions & 0 deletions docker-compose-sqlite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3.3" #docker version>=18.02.0+

services:
init-godnslog:
image: busybox
container_name: busybox
command: /bin/sh -c 'touch /app/db/godnslog.db && ls /app/db && chown -R 1000:1000 /app/db'
restart: "no"
volumes:
- godnslog-sqlite-data:/app/db

godnslog:
image: sort/godnslog
container_name: godnslog
restart: always
environment:
- GIN_MODE=release
ports:
- "8080:8080" # 反向代理模式
- "53:53/udp"
restart: always
command: serve -domain example.com -4 100.100.100.100 -dsn 'file:/app/db/godnslog.db?cache=shared&mode=rwc'
volumes:
- godnslog-sqlite-data:/app/db # 持久化存储

volumes:
godnslog-sqlite-data:
18 changes: 0 additions & 18 deletions docker-compose-standalone.yaml

This file was deleted.

0 comments on commit 6f0660a

Please sign in to comment.