forked from sqlpad/sqlpad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
74 lines (58 loc) · 1.96 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
74
FROM node:12.16.1-alpine AS build
RUN apk add --update --no-cache \
python \
make \
g++
WORKDIR /sqlpad
# By copying just the package files and installing node layers,
# we can take advantage of caching
# SQLPad is really 3 node projects though
# * root directory for linting
# * client/ for web front end
# * server/ for server (and what eventually holds built front end)
COPY ./package* ./
COPY ./client/package* ./client/
COPY ./server/package* ./server/
# Install dependencies
RUN npm ci
RUN npm ci --prefix client
RUN npm ci --prefix server
# Copy rest of the project into docker
COPY . .
# Build front-end and copy files into server public dir
RUN npm run build --prefix client && \
rm -rf server/public && \
mkdir server/public && \
cp -r client/build/* server/public
# Build test db used for dev, debugging and running tests
RUN node server/generate-test-db-fixture.js
# Run tests and linting to validate build
RUN npm run test --prefix server
RUN npm run lint
# Remove any dev dependencies from server
# We don't care about root or client directories
# as they are not going to be copied to next stage
WORKDIR /sqlpad/server
RUN npm prune --production
# Start another stage with a fresh node
# Copy the server directory that has all the necessary node modules + front end build
FROM node:12.16.1-alpine
WORKDIR /usr/app
COPY --from=build /sqlpad/docker-entrypoint /
COPY --from=build /sqlpad/server .
ENV NODE_ENV production
ENV SQLPAD_DB_PATH /var/lib/sqlpad
ENV SQLPAD_PORT 3000
EXPOSE 3000
ENTRYPOINT ["/docker-entrypoint"]
# Things to think about for future docker builds
# Perhaps add a healthcheck?
# Should nginx be used to front sqlpad?
#
# Should ODBC drivers be installed? (once ODBC is compiling that is)
#
# If you are wanting to use ODBC in docker build,
# fork this, make sure it compiles unixodbc driver in first stage,
# and add specific ODBC drivers here in this stage
RUN ["chmod", "+x", "/docker-entrypoint"]
WORKDIR /var/lib/sqlpad