Skip to content

Commit da8c1a9

Browse files
author
vsilent
committed
docker build and push prod
1 parent 53aa1ba commit da8c1a9

1 file changed

Lines changed: 95 additions & 0 deletions

File tree

.github/workflows/docker.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Docker CICD
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
cicd-linux-docker:
13+
name: CICD Linux for Docker
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout sources
17+
uses: actions/checkout@v2
18+
19+
- name: Install stable toolchain
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
toolchain: stable
23+
profile: minimal
24+
override: true
25+
26+
- name: Cache cargo registry
27+
uses: actions/cache@v1
28+
with:
29+
path: ~/.cargo/registry
30+
key: docker-registry-${{ hashFiles('**/Cargo.lock') }}
31+
restore-keys: |
32+
docker-registry-
33+
docker-
34+
35+
- name: Cache cargo index
36+
uses: actions/cache@v1
37+
with:
38+
path: ~/.cargo/git
39+
key: docker-index-${{ hashFiles('**/Cargo.lock') }}
40+
restore-keys: |
41+
docker-index-
42+
docker-
43+
44+
- name: Cache cargo build
45+
uses: actions/cache@v1
46+
with:
47+
path: target
48+
key: docker-build-${{ hashFiles('**/Cargo.lock') }}
49+
restore-keys: |
50+
docker-build-
51+
docker-
52+
53+
- name: Run cargo build
54+
uses: actions-rs/cargo@v1
55+
with:
56+
command: build
57+
args: --release
58+
59+
- name: Copy neccessary files and zip
60+
run: |
61+
mkdir app
62+
cp target/release/stackdog app/stackdog
63+
cp docker/prod/Dockerfile app/Dockerfile
64+
cd app
65+
touch .env
66+
tar -czvf ../app.tar.gz .
67+
cd ..
68+
69+
- name: Upload app archive for Docker job
70+
uses: actions/upload-artifact@v1
71+
with:
72+
name: artifact-linux-docker
73+
path: app.tar.gz
74+
75+
cicd-docker:
76+
name: CICD Docker
77+
runs-on: ubuntu-latest
78+
needs: cicd-linux-docker
79+
steps:
80+
- name: Download app archive
81+
uses: actions/download-artifact@v2
82+
with:
83+
name: artifact-linux-docker
84+
85+
- name: Extract app archive
86+
run: tar -zxvf app.tar.gz
87+
88+
- name: Docker build and publish
89+
uses: docker/build-push-action@v1
90+
with:
91+
username: ${{ secrets.DOCKER_USERNAME }}
92+
password: ${{ secrets.DOCKER_PASSWORD }}
93+
repository: trydirect/stackdog
94+
add_git_labels: true
95+
tag_with_ref: true

0 commit comments

Comments
 (0)