-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (46 loc) · 1.9 KB
/
Dockerfile
File metadata and controls
57 lines (46 loc) · 1.9 KB
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
# Ce fichier est le fruit de + de 48h de recherches
# contenant npm (un package manager) et alpine (os)
FROM node:18-alpine as base
WORKDIR /app
RUN if [[ $(uname -m) == "aarch64" ]] ; \
then \
# aarch64
# Installation de glibc version 2.26 (les versions antérieurs et ultérieurs ne fonctionnent pas)
wget https://raw.githubusercontent.com/squishyu/alpine-pkg-glibc-aarch64-bin/master/glibc-2.26-r1.apk ; \
apk add --no-cache --allow-untrusted --force-overwrite glibc-2.26-r1.apk ; \
rm glibc-2.26-r1.apk ; \
else \
# x86_64
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk ; \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub ; \
apk add --no-cache --force-overwrite glibc-2.28-r0.apk ; \
rm glibc-2.28-r0.apk ; \
fi
# Installation de bun pour installer les dépendances (plus rapide que npm)
RUN npm i -g bun
FROM base as install
# Installation des dépendances
COPY package.json .
RUN bun i
FROM install as build
# Construction de l'application
COPY . .
# Construction du projet
RUN bun run build
# Compilation (voir https://bun.sh/docs/bundler/executables)
# ------------------------
# Normally, Bun reads and transpiles JavaScript and TypeScript files on import and require.
# This is part of what makes so much of Bun "just work", but it's not free.
# It costs time and memory to read files from disk, resolve file paths, parse,
# transpile, and print source code.
RUN bun build --compile ./server/entry.elysia.js --outfile ./entry.elysia \
--target=bun --minify --sourcemap
# On utilise une image moins volumineuse (uniquement alpine & bun)
FROM oven/bun:alpine as production
WORKDIR /app
# On récupère les fichiers nécessaires pour l'application
COPY --from=build /app/dist ./dist
COPY --from=build /app/entry.elysia .
ENV PORT=5173
EXPOSE 5173
ENTRYPOINT ["./entry.elysia"]