Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b86257f

Browse files
author
zhenghongyi
committed
feat: 创建workflow文件,修改Dockerfile
1 parent d5a604d commit b86257f

File tree

5 files changed

+91
-1
lines changed

5 files changed

+91
-1
lines changed

‎.github/docker-image.yml‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
# 每次 push tag 时进行构建,不需要每次 push 都构建。使用通配符匹配每次 tag 的提交,记得 tag 名一定要以 v 开头
6+
tags:
7+
- v*
8+
9+
env:
10+
# 设置 docker 镜像名
11+
IMAGE_NAME: nginx-http-flv
12+
13+
jobs:
14+
# 运行测试,如果需要的话,将注释取消掉并且修改为自己需要的内容
15+
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
16+
# test:
17+
# runs-on: ubuntu-latest
18+
#
19+
# steps:
20+
# - uses: actions/checkout@v2
21+
#
22+
# - name: Run tests
23+
# run: |
24+
# if [ -f docker-compose.test.yml ]; then
25+
# docker-compose --file docker-compose.test.yml build
26+
# docker-compose --file docker-compose.test.yml run sut
27+
# else
28+
# docker build . --file Dockerfile
29+
# fi
30+
31+
# Push image to GitHub Packages.
32+
# See also https://docs.docker.com/docker-hub/builds/
33+
push:
34+
# 如果需要在构建前进行测试的话需要取消下面的注释和上面对应的 test 动作的注释。
35+
# needs: test
36+
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v2
40+
# 构建镜像,指定镜像名
41+
- name: Build image
42+
run: docker build . --file Dockerfile --tag $IMAGE_NAME
43+
# 登录到 dockerhub,使用 GitHub secrets 传入账号密码,密码被加密存储在 GitHub 服务器,添加方法见下图。
44+
- name: Log into registry
45+
run: echo "${{ secrets.ACCESS_TOKEN }}" | docker login -u clov614 --password-stdin
46+
47+
- name: Push image
48+
run: |
49+
# 拼接镜像 id,这个镜像 id 就是在使用 docker 镜像时 pull 后面的名字。
50+
IMAGE_ID=clov614/$IMAGE_NAME
51+
52+
# 将所有的大写字母转为小写
53+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
54+
55+
# 从 GitHub.ref 中取出版本
56+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),1,円')
57+
58+
# 从 tag 名字中替换 v 字符
59+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
60+
61+
# Use Docker `latest` tag convention
62+
[ "$VERSION" == "master" ] && VERSION=latest
63+
64+
echo IMAGE_ID=$IMAGE_ID
65+
echo VERSION=$VERSION
66+
# 设置镜像 id 和版本号
67+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
68+
# 进行 push
69+
docker push $IMAGE_ID:$VERSION

‎.idea/.gitignore‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/inspectionProfiles/Project_Default.xml‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/vcs.xml‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Dockerfile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ WORKDIR /workspace
1515

1616
# Get nginx and Get nginx-http-flv-module
1717
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories\
18-
&& apk add --no-cache g++ pcre-dev zlib-dev make openssl openssl-dev\
18+
&& apk update \
19+
&& apk add --no-cache g++ pcre-dev zlib-dev make openssl openssl-dev\
1920
&& wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz\
2021
&& tar -zxvf nginx-${NGINX_VERSION}.tar.gz\
2122
&& rm nginx-${NGINX_VERSION}.tar.gz\

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /