Advertisement
Guest User

Untitled

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