-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathDockerfile
More file actions
133 lines (115 loc) · 3.8 KB
/
Copy pathDockerfile
File metadata and controls
133 lines (115 loc) · 3.8 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# syntax=docker/dockerfile:1.7
FROM node:18 AS nodedeps
WORKDIR /source
COPY package.json package-lock.json .npmrc ./
ENV CI=true
RUN --mount=type=cache,target=/root/.npm npm ci --ignore-scripts
COPY proto proto
RUN npm run proto-copy-to-node
COPY public public
COPY src/client src/client
COPY index.html .
COPY src/index.js src/index.js
COPY src/setupTests.js src/setupTests.js
COPY vitest.config.js vite.config.js ./
FROM nodedeps AS nodebuilder
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN npm run build
FROM nodedeps AS nodetest
RUN npm run lint
RUN npm run test
FROM golang:1.25 AS godeps
# Install necessary packages for CGO
RUN apt-get update && apt-get install -y gcc
WORKDIR /source
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download -x
COPY src/proto src/proto
COPY src/server src/server
COPY sqlite sqlite
FROM godeps AS gobuilder
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 go build ./src/server
FROM godeps AS gotest
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go test -v -count=1 ./src/server/**/
FROM cypress/included:13.14.2 as e2etest
WORKDIR /dekart
RUN rm -f /etc/apt/sources.list.d/google-chrome.list \
&& rm -f /etc/apt/sources.list.d/microsoft-edge.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
gcc \
curl \
ca-certificates \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*
RUN update-ca-certificates
ENV DEKART_PORT=3000
ENV DEKART_STATIC_FILES=./build
ENV DEKART_SQLITE_DB_PATH=/dekart/data/dekart.db
ENV DEKART_STORAGE=USER
ENV DEKART_DATASOURCE=USER
ENV DEKART_ALLOW_FILE_UPLOAD=1
# ENV DEBUG=cypress:snapshot:error
COPY --from=nodebuilder /source/build build
COPY --from=gobuilder /source/server .
COPY migrations migrations
COPY sqlite sqlite
RUN mkdir -p /dekart/data/files
RUN mkdir -p keys
COPY keys/license-public.pem keys/license-public.pem
COPY cypress cypress
COPY cypress.config.js .
COPY --from=nodedeps /source/node_modules/dekart-proto node_modules/dekart-proto
COPY --from=nodedeps /source/node_modules/google-protobuf node_modules/google-protobuf
COPY package.json .
ENTRYPOINT /bin/sh -c /dekart/server & cypress run --spec ${TEST_SPEC}
FROM ubuntu:22.04
WORKDIR /dekart
RUN apt-get clean && apt-get update --allow-releaseinfo-change && apt-get install -y --no-install-recommends \
gcc \
ca-certificates \
&& apt-get -y autoremove && apt-get -y autoclean \
&& rm -rf /var/lib/apt/lists/*
RUN update-ca-certificates
COPY --from=nodebuilder /source/build build
COPY --from=gobuilder /source/server .
COPY migrations migrations
COPY sqlite sqlite
RUN mkdir -p keys
COPY keys/license-public.pem keys/license-public.pem
# Create a user and group
ARG USERNAME=appuser
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd -g $USER_GID $USERNAME \
&& useradd -m -u $USER_UID -g $USERNAME -s /bin/bash $USERNAME
# Set environment variables
ENV DEKART_PORT=8080
ENV DEKART_STATIC_FILES=./build
ENV DEKART_SQLITE_DB_PATH=/dekart/data/dekart.db
ENV DEKART_STORAGE=USER
ENV DEKART_DATASOURCE=USER
ENV DEKART_ALLOW_FILE_UPLOAD=1
ENV DEKART_LOCAL_FILES_ROOT=/dekart/data/files
ARG DEKART_MAPBOX_TOKEN
ENV DEKART_MAPBOX_TOKEN=${DEKART_MAPBOX_TOKEN}
ARG DEKART_UX_DISABLE_VERSION_CHECK
ARG DEKART_LICENSE_KEY
ENV DEKART_UX_DISABLE_VERSION_CHECK=${DEKART_UX_DISABLE_VERSION_CHECK}
ENV DEKART_LICENSE_KEY=${DEKART_LICENSE_KEY}
# Create local storage root used by zero-config uploads.
RUN mkdir -p /dekart/data/files
# Change ownership of the working directory to the new user
RUN chown -R $USERNAME:$USERNAME /dekart
# Switch to the non-root user
USER $USERNAME
# Expose the necessary port
EXPOSE 8080
# Run the server
CMD ["/dekart/server"]