forked from xizeyoupan/Meting-API
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
79 lines (56 loc) · 1.82 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
75
76
77
78
79
FROM alpine:3 as checkouter
RUN apk --no-cache add git
RUN git clone https://github.com/metowolf/Meting-API.git /meting-api \
&& cd /meting-api \
&& git checkout d7782b5
WORKDIR /meting-api
RUN sed -i 's/daemon off/daemon on/g' api/root/usr/local/bin/docker-entrypoint.sh \
&& echo -e "\nnode src/index.js" >> api/root/usr/local/bin/docker-entrypoint.sh \
&& sed '1a id' -i api/root/usr/local/bin/docker-entrypoint.sh \
&& sed -i 's/listen 80/listen 8080/g' api/root/etc/nginx/conf.d/default.conf \
&& sed -i 's/listen \[::\]:80/listen \[::\]:8080/g' api/root/etc/nginx/conf.d/default.conf
FROM node:17-alpine as prod
ARG UID
ARG GID
ENV UID=${UID:-1010}
ENV GID=${GID:-1010}
RUN addgroup -g ${GID} --system meting \
&& adduser -G meting --system -D -s /bin/sh -u ${UID} meting
COPY --from=0 /meting-api /meting-api
RUN apk update && apk add openrc \
php8 \
php8-fpm \
php8-opcache \
php8-bcmath \
php8-curl \
php8-mbstring \
php8-json \
php8-openssl \
composer \
nginx
# openrc
RUN mkdir -p /run/openrc && touch /run/openrc/softlevel
RUN cp -rp /meting-api/api/root/var/* /var/
# composer
RUN cd /var/www/meting \
&& composer install --no-dev --optimize-autoloader \
&& composer clearcache
# log
RUN chown -R nginx /var/log/nginx
# clean
RUN apk del composer && rm -rf /var/cache/apk/*
RUN cp -rp /meting-api/api/root/etc/* /etc \
&& cp -rp /meting-api/api/root/usr/* /usr
WORKDIR /meting-api/server
ARG NODE_ENV
ENV NODE_ENV ${NODE_ENV:-production}
ENV METING_API http://localhost:8080/api
RUN yarn
COPY server/src/config.js src/config.js
COPY server/src/service/api.js src/service/api.js
COPY server/src/index.js src/index.js
RUN chown -R meting:meting /var
RUN chown -R meting:meting /etc/php8
USER meting
EXPOSE 3000
ENTRYPOINT ["docker-entrypoint.sh"]