-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (25 loc) · 1.09 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Stage 1: Build the application
FROM alpine:latest AS builder
WORKDIR /usr/src/app
RUN apk --no-cache add curl jq
RUN latest_release=$(curl --silent "https://api.github.com/repos/dkhalife/tasks-backend/releases/latest" | jq -r .tag_name) && \
set -ex; \
apkArch="$(apk --print-arch)"; \
case "$apkArch" in \
armhf) arch='armv6' ;; \
armv7) arch='armv7' ;; \
aarch64) arch='arm64' ;; \
x86_64) arch='x86_64' ;; \
*) echo >&2 "error: unsupported architecture: $apkArch"; exit 1 ;; \
esac; \
curl -fL "https://github.com/dkhalife/tasks-backend/releases/download/${latest_release}/task-wizard_Linux_$arch.tar.gz" | tar -xz -C .
# Stage 2: Create a smaller runtime image
FROM alpine:latest
RUN apk --no-cache add curl ca-certificates libc6-compat
COPY --from=builder /usr/src/app/task-wizard /task-wizard
COPY --from=builder /usr/src/app/config /config
ENV TW_ENV="prod"
ENV GIN_MODE="release"
EXPOSE 2021
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD curl -s --fail http://localhost:2021/ping &> /dev/null || exit 1
CMD ["/task-wizard"]