-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile
61 lines (43 loc) · 1.59 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# syntax = docker/dockerfile:1
FROM jdxcode/mise:latest AS build
ARG VERSION=development
ARG COMMIT_SHA=development
ENV VERSION=${VERSION}
ENV COMMIT_SHA=${COMMIT_SHA}
WORKDIR /app
# Install unzip dependency for bun
RUN apt-get update && apt-get install -y unzip
# Install Taskfile
RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/bin
# Install language runtimes from .mise.toml
COPY /.mise.toml ./.mise.toml
RUN mise trust -a -y && mise install && mise activate --shims bash
# Cache build dependencies
ENV GOCACHE=/root/.cache/go-build
# Cache Go modules
COPY core/go.mod core/go.sum ./core/
COPY package.json bun.lock ./
COPY dashboard/package.json ./dashboard/
COPY tracker/package.json ./tracker/
RUN --mount=type=cache,target=${GOCACHE} \
--mount=type=cache,target=/go/pkg/mod \
cd core && go mod download && cd ..
RUN bun install --frozen-lockfile
# Verify environment variables
RUN echo "VERSION=${VERSION}" && echo "COMMIT_SHA=${COMMIT_SHA}"
# Copy the rest of the source code
COPY . .
RUN --mount=type=cache,target=${GOCACHE} ~/bin/task core:release:docker
# Build the final image
FROM gcr.io/distroless/cc-debian12
LABEL org.opencontainers.image.source=https://github.com/medama-io/medama \
org.opencontainers.image.description="Cookie-free, privacy-focused website analytics." \
org.opencontainers.image.licenses=Apache-2.0
ENV PORT=8080 \
ANALYTICS_DATABASE_HOST=/app/data/me_analytics.db \
APP_DATABASE_HOST=/app/data/me_app.db
WORKDIR /app
# Copy the binary
COPY --from=build /app/core/bin/main /app/bin/main
EXPOSE ${PORT}
CMD ["/app/bin/main", "start", "-env"]