-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackend.Dockerfile
71 lines (54 loc) · 1.93 KB
/
backend.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
FROM debian:buster-slim as node-base
LABEL author="Max Meinhold <[email protected]>"
# Yarn and nvm install deps
RUN rm /bin/sh \
&& ln -s /bin/bash /bin/sh \
&& apt-get update \
&& apt-get install -y curl \
&& apt-get -y autoclean
# NVM and node install
ENV NODE_VERSION 14.8.0
ENV NVM_DIR /usr/local/nvm
RUN mkdir $NVM_DIR \
&& curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh | bash
RUN source $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
FROM node-base as builder
# Yarn install deps
RUN rm /bin/sh \
&& ln -s /bin/bash /bin/sh \
&& apt-get update \
&& apt-get install -y gnupg \
&& apt-get -y autoclean
WORKDIR /usr/src/deadass
# Yarn install
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y yarn \
&& apt-get -y autoclean
# Project dependencies
RUN mkdir ./backend && mkdir ./frontend
COPY package.json yarn.lock ./
COPY backend/package.json ./backend/
COPY frontend/package.json ./frontend/
RUN yarn install
# Build the bundle
COPY . .
RUN yarn workspace @csh/deadass-backend run build:production
FROM node-base as backend
WORKDIR /opt/deadass
# Wordlist - The american dictionary, removing apostrophes, short words, accent marks
RUN apt-get update \
&& apt-get install -y wamerican \
&& cat /usr/share/dict/words | grep -v "'" | awk '{ if (length($0) > 2) print tolower($0)}' | grep -Pv '[^\x00-\x7F]' | uniq > words.txt \
&& apt-get purge -y wamerican
COPY --from=builder /usr/src/deadass/backend/dist/bundle.js ./
COPY ./backend/config.example.json ./
EXPOSE 8080
USER 1001
CMD ["node", "bundle.js"]