1
0
ohmyform/Dockerfile
2022-01-13 16:47:35 +01:00

74 lines
1.9 KiB
Docker

## Build UI
FROM node:14-alpine as ui
WORKDIR /usr/src/ui
RUN apk update && apk add curl bash && rm -rf /var/cache/apk/*
# install node-prune (https://github.com/tj/node-prune)
RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin
COPY ui/ .
RUN yarn install --frozen-lockfile
RUN yarn build
# remove development dependencies
RUN npm prune --production
# run node prune
# there is some problem running node prune that then prevents the frontend to load (just start with /form/1 and it will crash)
#RUN /usr/local/bin/node-prune
## Build API
FROM node:14-alpine as api
LABEL maintainer="OhMyForm <admin@ohmyform.com>"
WORKDIR /usr/src/api
RUN apk --update add curl bash && rm -rf /var/cache/apk/*
# install node-prune (https://github.com/tj/node-prune)
RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin
COPY api/ .
RUN touch /usr/src/api/src/schema.gql && chown 9999:9999 /usr/src/api/src/schema.gql
RUN yarn install --frozen-lockfile
RUN yarn build
# remove development dependencies
RUN npm prune --production
# run node prune
RUN /usr/local/bin/node-prune
## Production Image.
FROM node:14-alpine
RUN apk --update add supervisor nginx && rm -rf /var/cache/apk/*
WORKDIR /usr/src
COPY --from=api /usr/src/api /usr/src/api
COPY --from=ui /usr/src/ui /usr/src/ui
RUN addgroup --gid 9999 ohmyform && adduser -D --uid 9999 -G ohmyform ohmyform
ENV SECRET_KEY=ChangeMe \
CREATE_ADMIN=FALSE \
ADMIN_EMAIL=admin@ohmyform.com \
ADMIN_USERNAME=root \
ADMIN_PASSWORD=root \
NODE_ENV=production
EXPOSE 3000
RUN mkdir -p /run/nginx/
RUN touch /usr/src/supervisord.log && chmod 777 /usr/src/supervisord.log
COPY supervisord.conf /etc/supervisord.conf
COPY nginx.conf /etc/nginx/nginx.conf
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
# CMD [ "yarn", "start:prod" ]