This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chaoyue
committed
Apr 9, 2018
1 parent
953a6c1
commit dcd906b
Showing
4 changed files
with
185 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
#sudo docker build -t centos7-gopub . | ||
#sudo docker run --name centos7-gopub -d centos7-gopub:latest | ||
From 192.168.176.2:81/test/centos7-gopub | ||
MAINTAINER Linc "13579443@qq.com" | ||
#docker 17.05+版本支持 | ||
#sudo docker build -t gopub . | ||
#sudo docker run --name gopub -p 8192:8192 --restart always -d gopub:latest | ||
FROM golang:1.10.1-alpine3.7 as golang | ||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \ | ||
apk update && \ | ||
apk add bash && \ | ||
rm -rf /var/cache/apk/* /tmp/* | ||
ADD src/ /data/gopub/src/ | ||
ADD control /data/gopub/control | ||
RUN cd /data/gopub &&./control build | ||
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"] | ||
WORKDIR /data/gopub/ | ||
RUN ./control build | ||
|
||
FROM node:9.11.1-alpine as node | ||
ADD ./ /data/gopub/ | ||
WORKDIR /data/gopub/vue-gopub | ||
RUN npm install && npm run build | ||
|
||
FROM alpine:3.7 | ||
MAINTAINER Linc "13579443@qq.com" | ||
ENV TZ='Asia/Shanghai' | ||
RUN TERM=linux && export TERM | ||
USER root | ||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \ | ||
apk update && \ | ||
apk add ca-certificates bash tzdata sudo curl wget openssh git && \ | ||
echo "Asia/Shanghai" > /etc/timezone && \ | ||
cp -r -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ | ||
rm -rf /var/cache/apk/* /tmp/* && \ | ||
mkdir -p /data/htdocs && \ | ||
mkdir -p /data/logs && \ | ||
ssh-keygen -q -N "" -f /root/.ssh/id_rsa && \ | ||
#输出的key需要加入发布目标机的 ~/.ssh/authorized_keys | ||
cat ~/.ssh/id_rsa.pub | ||
WORKDIR /data/gopub | ||
ADD control /data/gopub/control | ||
COPY --from=golang /data/gopub/src/gopub /data/gopub/src/gopub | ||
COPY --from=golang /data/gopub/src/conf /data/gopub/src/conf | ||
COPY --from=golang /data/gopub/src/logs /data/gopub/src/logs | ||
COPY --from=golang /data/gopub/src/agent /data/gopub/src/agent | ||
COPY --from=node /data/gopub/src/views /data/gopub/src/views | ||
COPY --from=node /data/gopub/src/static /data/gopub/src/static | ||
CMD ["./control","rundocker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: gopub | ||
namespace: default | ||
labels: | ||
name: gopub | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: gopub | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 1 | ||
maxUnavailable: 1 | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
name: gopub | ||
spec: | ||
restartPolicy: Always | ||
hostAliases: | ||
- ip: "192.168.162.66" | ||
hostnames: | ||
- "gitlab.example.org" | ||
- "packagist.example.org" | ||
- "toran.example.org" | ||
- ip: "192.168.143.41" | ||
hostnames: | ||
- "jenkins.example.org" | ||
- ip: "127.0.0.1" | ||
hostnames: | ||
- "mysql" | ||
containers: | ||
- name: gopub | ||
image: "lc13579443/gopub:latest" | ||
imagePullPolicy: Always | ||
securityContext: | ||
privileged: true | ||
ports: | ||
- containerPort: 8192 | ||
name: http-port | ||
env: | ||
- name: MYSQL_HOST | ||
value: '127.0.0.1' | ||
- name: MYSQL_PORT | ||
value: '3306' | ||
- name: MYSQL_USER | ||
value: 'root' | ||
- name: MYSQL_PASS | ||
value: '123456' | ||
- name: MYSQL_DB | ||
value: 'walle' | ||
resources: | ||
limits: | ||
cpu: 2 | ||
memory: 4096Mi | ||
requests: | ||
cpu: 100m | ||
memory: 200Mi | ||
volumeMounts: | ||
- name: localtime | ||
mountPath: /etc/localtime | ||
readOnly: true | ||
- name: cgroup | ||
mountPath: /sys/fs/cgroup | ||
readOnly: true | ||
- name: mysql | ||
image: "mysql:5.7" | ||
imagePullPolicy: Always | ||
env: | ||
- name: MYSQL_ROOT_PASSWORD | ||
value: '123456' | ||
ports: | ||
- containerPort: 3306 | ||
name: mysql-port | ||
resources: | ||
limits: | ||
cpu: 2 | ||
memory: 4096Mi | ||
requests: | ||
cpu: 100m | ||
memory: 200Mi | ||
volumeMounts: | ||
- name: localtime | ||
mountPath: /etc/localtime | ||
readOnly: true | ||
- name: cgroup | ||
mountPath: /sys/fs/cgroup | ||
readOnly: true | ||
- name: mysql-data | ||
mountPath: /var/lib/mysql | ||
terminationGracePeriodSeconds: 30 | ||
volumes: | ||
- name: localtime | ||
hostPath: | ||
path: /etc/localtime | ||
- name: cgroup | ||
hostPath: | ||
path: /sys/fs/cgroup | ||
- name: mysql-data | ||
hostPath: | ||
path: /data/gopub-mysql | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: gopub | ||
namespace: default | ||
labels: | ||
name: gopub | ||
spec: | ||
type: NodePort | ||
selector: | ||
name: gopub | ||
ports: | ||
- name: gopub | ||
port: 8192 | ||
nodePort: 8192 | ||
|