Skip to content

Commit c2f705a

Browse files
committed
move to github actiion + do.sh / update deps
1 parent 2786d4a commit c2f705a

8 files changed

Lines changed: 100 additions & 48 deletions

File tree

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
node_modules/
66
/proxy
77
**/.terraform/
8-
!target/x86_64-unknown-linux-musl/release/dino-park-whoami
8+
!target/release/dino-park-whoami

.github/workflows/rust.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Run fmt
20+
run: cargo fmt --all -- --check
21+
- name: Clippy
22+
run: cargo clippy --all --all-features -- -D warnings
23+
- name: Build
24+
run: cargo build --all --all-features --verbose
25+
- name: Run tests
26+
run: cargo test --all --all-features
27+

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
FROM rust:latest
22

3-
RUN rustup target add x86_64-unknown-linux-musl
4-
RUN apt-get update && apt-get install -y \
5-
musl-tools \
6-
&& rm -rf /var/lib/apt/lists/*
73
WORKDIR /usr/src/app
84
COPY . .
9-
RUN cargo build --release --target x86_64-unknown-linux-musl
5+
RUN cargo build --release
6+
7+
FROM debian:10-slim
108

11-
FROM alpine:latest
9+
RUN apt-get update && apt-get install -y \
10+
ca-certificates \
11+
&& rm -rf /var/lib/apt/lists/*
1212

1313
WORKDIR /root/
14-
COPY --from=0 /usr/src/app/target/x86_64-unknown-linux-musl/release/dino-park-whoami .
15-
CMD ["./dino-park-whoami"]
14+
COPY --from=0 /usr/src/app/target/release/dino-park-whoami .
15+
CMD ["./dino-park-whoami"]

Dockerfile.local

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
FROM alpine:latest
1+
FROM debian:10-slim
2+
3+
RUN apt-get update && apt-get install -y \
4+
ca-certificates \
5+
&& rm -rf /var/lib/apt/lists/*
26

37
WORKDIR /root/
4-
COPY target/x86_64-unknown-linux-musl/release/dino-park-whoami .
5-
CMD ["./dino-park-whoami"]
8+
COPY target/release/dino-park-whoami .
9+
CMD ["./dino-park-whoami"]

buildspec.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ phases:
77
pre_build:
88
commands:
99
- export COMMIT_SHA=$CODEBUILD_RESOLVED_SOURCE_VERSION
10+
- export REV=$COMMIT_SHA
1011
- export CODEBUILD_WEBHOOK_TRIGGER=${CODEBUILD_WEBHOOK_TRIGGER:-branch/master}
1112
- export DEPLOY_ENV=$(echo $CODEBUILD_WEBHOOK_TRIGGER | sed -e 's/tag\/.*-\(.*\)/\1/' | sed -e 's/branch\/master/dev/')
1213
- export PR=$(if case $CODEBUILD_WEBHOOK_TRIGGER in pr/*) ;; *) false;; esac; then echo 1; fi)
@@ -17,12 +18,12 @@ phases:
1718
- aws ecr get-login --region us-west-2 --no-include-email | bash
1819
build:
1920
commands:
20-
- if [ "$PR" = 1 ]; then myke package-local; fi
21-
- if [ "$MASTER" = 1 ]; then myke package-local --rev=$COMMIT_SHA push-image --rev=$COMMIT_SHA; fi
21+
- if [ "$PR" = 1 ]; then ./do.sh package_local; fi
22+
- if [ "$MASTER" = 1 ]; then ./do.sh package_local && ./do.sh push_image; fi
2223
post_build:
2324
commands:
2425
- echo "Environment is ${DEPLOY_ENV}"
25-
- if [ "$PR" = "" ]; then myke deploy --deploy_env=$DEPLOY_ENV --rev=$COMMIT_SHA; fi
26+
- if [ "$PR" = "" ]; then ./do.sh deploy; fi
2627
cache:
2728
paths:
2829
- $HOME/.cargo

ci/install_deps.sh

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
export RUSTUP_HOME=/usr/local/rustup
22
export CARGO_HOME=/usr/local/cargo
33
export PATH=/usr/local/cargo/bin:$PATH
4-
export RUST_VERSION=1.42.0
4+
export RUST_VERSION=1.46.0
55

66
set -eux
77
dpkgArch="$(dpkg --print-architecture)"
88
case "${dpkgArch##*-}" in
9-
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b' ;;
10-
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='6c6c3789dabf12171c7f500e06d21d8004b5318a5083df8b0b02c0e5ef1d017b' ;;
11-
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='26942c80234bac34b3c1352abbd9187d3e23b43dae3cf56a9f9c1ea8ee53076d' ;;
12-
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='27ae12bc294a34e566579deba3e066245d09b8871dc021ef45fc715dced05297' ;;
9+
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='49c96f3f74be82f4752b8bffcf81961dea5e6e94ce1ccba94435f12e871c3bdb' ;;
10+
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='5a2be2919319e8778698fa9998002d1ec720efe7cb4f6ee4affb006b5e73f1be' ;;
11+
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='d93ef6f91dab8299f46eef26a56c2d97c66271cea60bf004f2f088a86a697078' ;;
12+
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e3d0ae3cfce5c6941f74fed61ca83e53d4cd2deb431b906cbd0687f246efede4' ;;
1313
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;;
14-
esac
15-
url="https://static.rust-lang.org/rustup/archive/1.21.1/${rustArch}/rustup-init"
14+
esac;
15+
url="https://static.rust-lang.org/rustup/archive/1.22.1/${rustArch}/rustup-init";
1616
wget "$url"
1717
echo "${rustupSha256} *rustup-init" | sha256sum -c -
1818
chmod +x rustup-init
@@ -23,11 +23,6 @@ rustup --version
2323
cargo --version
2424
rustc --version
2525

26-
rustup target add x86_64-unknown-linux-musl
27-
apt-get update
28-
apt-get install -y musl-tools
26+
rustup target add x86_64-unknown-linux-gnu
2927
HELM_INSTALL_DIR=/bin
30-
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash
31-
curl -L -o myke https://github.com/fiji-flo/myke/releases/download/0.9.11/myke-0.9.11-x86_64-unknown-linux-musl
32-
chmod +x ./myke
33-
mv ./myke /bin/myke
28+
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash

do.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
NAME=dino-park-whoami
6+
DOCKER_REGISTRY=320464205386.dkr.ecr.us-west-2.amazonaws.com
7+
REV=${REV:-latest}
8+
9+
compile_release() {
10+
cargo build --release
11+
}
12+
13+
docker_build_local() {
14+
docker build -t ${DOCKER_REGISTRY}/${NAME}:${REV} -f Dockerfile.local .
15+
}
16+
17+
docker_build() {
18+
docker build -t ${DOCKER_REGISTRY}/${NAME}:${REV} -f Dockerfile .
19+
}
20+
21+
package_local() {
22+
compile_release
23+
docker_build_local
24+
}
25+
26+
push_image() {
27+
docker push ${DOCKER_REGISTRY}/${NAME}:${REV}
28+
}
29+
30+
deploy() {
31+
if [ -z ${DEPLOY_ENV} ]; then exit 1; fi
32+
helm template -f k8s/values.yaml -f k8s/values/${DEPLOY_ENV}.yaml \
33+
--set docker_registry=${DOCKER_REGISTRY},rev=${REV} k8s/ | kubectl apply -f -
34+
}
35+
36+
if [ -z ${1} ]
37+
then
38+
echo "usage: $0 [command]"
39+
echo
40+
echo "commands:"
41+
declare -F | sed "s/declare -f /\t/g"
42+
else
43+
$1
44+
fi

0 commit comments

Comments
 (0)