Skip to content

Commit 9509675

Browse files
committed
ci
fix(ci): permission fix(ci): checkout version fix(ci): buildx fix(ci): image tag fix(ci): image tag
1 parent 976f25a commit 9509675

File tree

4 files changed

+149
-0
lines changed

4 files changed

+149
-0
lines changed

.dockerignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel
35+
36+
**/*.trace
37+
**/*.zip
38+
**/*.tar.gz
39+
**/*.tgz
40+
**/*.log
41+
package-lock.json
42+
**/*.bun
43+
44+
gen
45+
data

.github/workflows/ci.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
packages: write
14+
steps:
15+
- uses: docker/setup-qemu-action@v3
16+
17+
- uses: docker/setup-buildx-action@v3
18+
19+
- uses: docker/login-action@v3
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- uses: docker/build-push-action@v5
26+
with:
27+
tags: ghcr.io/thinc-org/10days-paotooong
28+
push: true
29+
cache-from: type=gha
30+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM golang:1.21.3 AS builder
2+
3+
WORKDIR /build
4+
5+
COPY go.mod go.sum .
6+
7+
RUN go get ./...
8+
9+
RUN BIN="/usr/local/bin" && \
10+
VERSION="1.27.1" && \
11+
curl -sSL \
12+
"https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" \
13+
-o "${BIN}/buf" && \
14+
chmod +x "${BIN}/buf" && \
15+
apt-get update && \
16+
apt-get install -y ca-certificates curl gnupg && \
17+
mkdir -p /etc/apt/keyrings && \
18+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
19+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
20+
apt-get update && \
21+
apt-get install nodejs -y && \
22+
go install \
23+
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
24+
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
25+
google.golang.org/protobuf/cmd/protoc-gen-go \
26+
google.golang.org/grpc/cmd/protoc-gen-go-grpc
27+
28+
COPY . .
29+
30+
RUN go generate .
31+
32+
RUN CGO_ENABLED=0 go build ./cmd/proxy
33+
34+
RUN CGO_ENABLED=0 go build ./cmd/grpc
35+
36+
FROM debian:bullseye-slim AS master
37+
38+
WORKDIR /app
39+
40+
COPY --from=builder /build/proxy .
41+
42+
COPY --from=builder /build/grpc .
43+
44+
COPY docker/entrypoint.sh /docker-entrypoint.d/entrypoint.sh
45+
46+
ENTRYPOINT [ "/docker-entrypoint.d/entrypoint.sh" ]
47+
48+
CMD [ "proxy" ]

docker/entrypoint.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
show_usage() {
4+
echo "$0 [proxy|grpc]"
5+
exit 1
6+
}
7+
8+
if [ $# -ne 1 ]; then
9+
show_usage
10+
fi
11+
12+
case $1 in
13+
grpc)
14+
echo "Starting grpc server"
15+
/app/grpc
16+
;;
17+
proxy)
18+
echo "Starting http server"
19+
/app/proxy
20+
;;
21+
*)
22+
echo "Invalid option"
23+
show_usage
24+
;;
25+
esac
26+

0 commit comments

Comments
 (0)