Advertisement
Guest User

BookBrainzDocker

a guest
Oct 20th, 2021
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. FROM metabrainz/node:16 as bookbrainz-base
  2.  
  3. ARG DEPLOY_ENV
  4. ARG GIT_COMMIT_SHA
  5.  
  6. ARG BUILD_DEPS=" \
  7. build-essential \
  8. python-dev \
  9. libpq5 \
  10. libpq-dev"
  11.  
  12. ARG RUN_DEPS=" \
  13. bzip2 \
  14. git \
  15. rsync"
  16.  
  17.  
  18. RUN apt-get update && \
  19. apt-get install --no-install-suggests --no-install-recommends -y \
  20. $BUILD_DEPS $RUN_DEPS && \
  21. rm -rf /var/lib/apt/lists/*
  22.  
  23. # PostgreSQL client
  24. RUN apt-get update
  25. RUN apt-get install ca-certificates
  26. RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
  27. ENV PG_MAJOR 12
  28. RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
  29. RUN apt-get update \
  30. && apt-get install -y --no-install-recommends postgresql-client-$PG_MAJOR \
  31. && rm -rf /var/lib/apt/lists/*
  32.  
  33. # Clean up files that aren't needed for production
  34. RUN apt-get remove -y $BUILD_DEPS && \
  35. apt-get autoremove -y
  36.  
  37. RUN useradd --create-home --shell /bin/bash bookbrainz
  38.  
  39. ARG BB_ROOT=/home/bookbrainz/bookbrainz-site
  40. WORKDIR $BB_ROOT
  41. RUN chown bookbrainz:bookbrainz $BB_ROOT
  42.  
  43. RUN echo $GIT_COMMIT_SHA > .git-version
  44.  
  45. # Files necessary to complete the JavaScript build
  46. COPY --chown=bookbrainz scripts/ scripts/
  47. COPY --chown=bookbrainz .babelrc .eslintrc.js .eslintignore webpack.client.js package.json package-lock.json ./
  48.  
  49. RUN npm install --no-audit
  50.  
  51. COPY --chown=bookbrainz static/ static/
  52. COPY --chown=bookbrainz config/ config/
  53. COPY --chown=bookbrainz sql/ sql/
  54. COPY --chown=bookbrainz src/ src/
  55.  
  56.  
  57. # Development target
  58. FROM bookbrainz-base as bookbrainz-dev
  59. ARG DEPLOY_ENV
  60.  
  61. CMD ["npm", "start"]
  62.  
  63. # Production target
  64. FROM bookbrainz-base as bookbrainz-prod
  65. ARG DEPLOY_ENV
  66.  
  67. COPY ./docker/$DEPLOY_ENV/rc.local /etc/rc.local
  68. RUN chmod 755 /etc/rc.local
  69.  
  70. COPY ./docker/consul-template-webserver.conf /etc/consul-template-webserver.conf
  71. COPY ./docker/$DEPLOY_ENV/webserver.command /etc/service/webserver/exec-command
  72. RUN chmod +x /etc/service/webserver/exec-command
  73. COPY ./docker/$DEPLOY_ENV/webserver.service /etc/service/webserver/run
  74. RUN chmod 755 /etc/service/webserver/run
  75. RUN touch /etc/service/webserver/down
  76.  
  77. # Set up cron jobs and DB dumps
  78. RUN mkdir -p /home/bookbrainz/data/dumps
  79.  
  80. COPY ./docker/consul-template-cron.conf /etc/consul-template-cron.conf
  81. COPY ./docker/cron.service /etc/service/cron/run
  82. RUN touch /etc/service/cron/down
  83.  
  84. ADD ./docker/crontab /etc/cron.d/bookbrainz
  85. RUN chmod 0644 /etc/cron.d/bookbrainz && crontab -u bookbrainz /etc/cron.d/bookbrainz
  86.  
  87. # Build JS project and assets
  88. USER bookbrainz
  89. RUN ["npm", "run", "build"]
  90. RUN ["npm", "prune", "--production"]
  91. USER root
  92.  
  93. # API target
  94. FROM bookbrainz-base as bookbrainz-webservice
  95. ARG DEPLOY_ENV
  96.  
  97. COPY ./docker/$DEPLOY_ENV/rc.local /etc/rc.local
  98. RUN chmod 755 /etc/rc.local
  99.  
  100. COPY ./docker/consul-template-webserver.conf /etc/consul-template-webserver.conf
  101. COPY ./docker/$DEPLOY_ENV/webserver.command /etc/service/webserver/exec-command
  102. RUN chmod +x /etc/service/webserver/exec-command
  103. COPY ./docker/$DEPLOY_ENV/webserver.service /etc/service/webserver/run
  104. RUN chmod 755 /etc/service/webserver/run
  105. RUN touch /etc/service/webserver/down
  106.  
  107. # Build API JS
  108. USER bookbrainz
  109. RUN ["npm", "run", "build-api-js"]
  110. RUN ["npm", "prune", "--production"]
  111. USER root
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement