-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
73 lines (51 loc) · 2.22 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
62
63
64
65
66
67
68
69
70
71
72
73
# ========================================
# CORE IMAGE
# ========================================
FROM oven/bun:1 AS core
# ========================================
# BASE IMAGE
# ========================================
FROM core AS base
ENV BUN_INSTALL_CACHE_DIR="/bun/install/cache"
RUN mkdir -p /var/lib/ladesa/.sources
RUN chown -R 1000:1000 /var/lib/ladesa/.sources
WORKDIR "/var/lib/ladesa/.sources/api/"
# ========================================
# DEVELOPMENT AND BUILD DEPENDENCIES
# ========================================
FROM base AS dev-dependencies
RUN mkdir -p /var/lib/ladesa/.builds
COPY . "/var/lib/ladesa/.sources/api"
RUN --mount=type=cache,id=bun,target=/bun/install/cache bun install --frozen-lockfile
# ========================================
# API-SERVICE - BUILD
# ========================================
FROM dev-dependencies AS api-service-builder
RUN cp -r /var/lib/ladesa/.sources/api/api-service /var/lib/ladesa/.builds/api-service
WORKDIR /var/lib/ladesa/.builds/api-service
RUN --mount=type=cache,id=bun,target=/bun/install/cache bun install
# ========================================
# NPM / API-CLIENT-FETCH / DOCS -- BUILD
# ========================================
FROM dev-dependencies AS docs-npm-api-client-fetch-builder
RUN bun run --filter "@ladesa-ro/api-client-fetch.docs" build
RUN cp -r /var/lib/ladesa/.sources/api/docs/docs-npm-api-client-fetch "/var/lib/ladesa/.builds/npm-api-client-fetch-docs"
# ========================================
# NPM / API-CLIENT-FETCH / DOCS -- RUNTIME
# ========================================
FROM nginx:alpine AS docs-npm-api-client-fetch-runtime
COPY \
./docs/docs-npm-api-client-fetch/nginx.conf \
/etc/nginx/nginx.conf
COPY --from=docs-npm-api-client-fetch-builder "/var/lib/ladesa/.builds/npm-api-client-fetch-docs" "/usr/local/ladesa-ro/services/npm-api-client-fetch-docs"
EXPOSE 80
# ========================================
# API-SERVICE -- RUNTIME
# ========================================
FROM core AS api-service-runtime
USER bun
COPY --from=api-service-builder \
"/var/lib/ladesa/.builds/api-service" \
"/usr/local/ladesa-ro/services/api-service"
WORKDIR "/usr/local/ladesa-ro/services/api-service"
CMD bun run migration:run && bun run start:prod