Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
order dockerfiles
Browse files Browse the repository at this point in the history
microstudi committed Sep 22, 2023
1 parent b92149e commit 8d0de46
Showing 7 changed files with 120 additions and 125 deletions.
1 change: 0 additions & 1 deletion Dockerfile

This file was deleted.

101 changes: 101 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# This stage builds the python-wrapper package
FROM decidim/ruby-node-python-electionguard:ruby-3.1.1-node-16-python-3.8.11-electionguard-1.2.3 as python-wrapper-builder
LABEL author="hola@decidim.org"

# Add Makefiles
ADD Makefile /code/Makefile
ADD bulletin_board/server.mk /code/bulletin_board/server.mk
ADD bulletin_board/client.mk /code/bulletin_board/client.mk
ADD voting_schemes/dummy/makefile.mk /code/voting_schemes/dummy/makefile.mk
ADD voting_schemes/electionguard/makefile.mk /code/voting_schemes/electionguard/makefile.mk
ADD verifier/makefile.mk /code/verifier/makefile.mk

# Add the source files
ADD voting_schemes/electionguard/python-wrapper /code/voting_schemes/electionguard/python-wrapper

# This step builds the electionguard-python package and the python wrapper
RUN cd /code && make build_electionguard_python_wrapper

# This stage builds the pyodide packages for the previous python packages
FROM decidim/pyodide-electionguard:pyodide-0.16.1-electionguard-1.2.3 as python-to-js-builder
LABEL author="hola@decidim.org"

ENV PYODIDE_PACKAGES "electionguard,bulletin_board-electionguard"

# Create the source folder
RUN mkdir -p /code

# Add the source files
COPY --from=python-wrapper-builder /code/voting_schemes/electionguard /code/voting_schemes/electionguard
ADD voting_schemes/electionguard/python-to-js /code/voting_schemes/electionguard/python-to-js

# Copy packages definitions to the pyodide source folder
RUN cp -r /code/voting_schemes/electionguard/python-to-js/packages/* /src/pyodide/packages

# Copy the python packages
RUN cp -r /code/voting_schemes/electionguard/electionguard-python/dist /src/pyodide/packages/electionguard/dist
RUN cp -r /code/voting_schemes/electionguard/python-wrapper/dist /src/pyodide/packages/bulletin_board-electionguard/dist

# This step compiles both packages using pyodide
RUN make

# Override some files in the pyodide build
RUN cp -rf /code/voting_schemes/electionguard/python-to-js/override/* /src/pyodide/build/

# This stage builds the bulletin-board application
FROM decidim/ruby-node-python-electionguard:ruby-3.1.1-node-16-python-3.8.11-electionguard-1.2.3
LABEL author="hola@decidim.org"

# Dummy environment variables used to compile assets
ENV SECRET_KEY_BASE 1234
ENV RAILS_ENV production

# Install system dependencies
RUN apt-get update --allow-releaseinfo-change && \
apt-get install -y postgresql postgresql-client postgresql-contrib libpq-dev \
redis-server memcached imagemagick ffmpeg mupdf mupdf-tools libxml2-dev curl && \
rm -rf /var/lib/apt/lists/*

# Add Makefiles
ADD Makefile /code/Makefile
ADD bulletin_board/server.mk /code/bulletin_board/server.mk
ADD bulletin_board/client.mk /code/bulletin_board/client.mk
ADD voting_schemes/dummy/makefile.mk /code/voting_schemes/dummy/makefile.mk
ADD voting_schemes/electionguard/makefile.mk /code/voting_schemes/electionguard/makefile.mk
ADD verifier/makefile.mk /code/verifier/makefile.mk

# Add local dependencies and copy some artifacts from previous stages
ADD bulletin_board/js-client /code/bulletin_board/js-client
ADD bulletin_board/ruby-client /code/bulletin_board/ruby-client
ADD voting_schemes/dummy/js-adapter /code/voting_schemes/dummy/js-adapter
ADD voting_schemes/dummy/ruby-adapter /code/voting_schemes/dummy/ruby-adapter
COPY --from=python-to-js-builder /code/voting_schemes/electionguard /code/voting_schemes/electionguard
ADD voting_schemes/electionguard/js-adapter /code/voting_schemes/electionguard/js-adapter
ADD voting_schemes/electionguard/ruby-adapter /code/voting_schemes/electionguard/ruby-adapter
COPY --from=python-to-js-builder /src/pyodide/build /code/voting_schemes/electionguard/ruby-adapter/public/assets/electionguard

# Add dependencies manifests
ADD bulletin_board/server/package-lock.json /code/bulletin_board/server/package-lock.json
ADD bulletin_board/server/package.json /code/bulletin_board/server/package.json
ADD bulletin_board/server/Gemfile.lock /code/bulletin_board/server/Gemfile.lock
ADD bulletin_board/server/Gemfile /code/bulletin_board/server/Gemfile

# Install all dependencies, build artifacts and remove unnecessary files
RUN cd /code && make install && make build SKIP_PYODIDE=true && \
rm -rf /code/bulletin_board/js-client && \
rm -rf /code/voting_schemes/dummy/js-adapter && \
rm -rf /code/voting_schemes/electionguard/js-adapter && \
rm -rf /root/.cache/Cypress

# Add application source code
ADD bulletin_board/server /code/bulletin_board/server
WORKDIR /code/bulletin_board/server

# Precompile assets
RUN npm install --global yarn
RUN bundle
RUN bundle exec rake assets:precompile

COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["bundle", "exec", "rails", "s", "-b", "0.0.0.0"]
6 changes: 2 additions & 4 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ ENV RAILS_ENV production
# Install system dependencies
RUN apt-get update --allow-releaseinfo-change && \
apt-get install -y postgresql postgresql-client postgresql-contrib libpq-dev \
redis-server memcached imagemagick ffmpeg mupdf mupdf-tools libxml2-dev && \
redis-server memcached imagemagick ffmpeg mupdf mupdf-tools libxml2-dev curl && \
rm -rf /var/lib/apt/lists/*

# Add Makefiles
@@ -96,6 +96,4 @@ RUN npm install --global yarn
RUN bundle
RUN bundle exec rake assets:precompile

ENTRYPOINT ["/docker-entrypoint.sh"]
COPY ./docker-entrypoint.sh /
CMD ["bundle", "exec", "rails", "s", "-b", "0.0.0.0"]
CMD ["bundle", "exec", "rake", "db:migrate"]
102 changes: 0 additions & 102 deletions Dockerfile.web

This file was deleted.

29 changes: 14 additions & 15 deletions Dockerfile.worker
Original file line number Diff line number Diff line change
@@ -2,16 +2,16 @@
FROM decidim/ruby-node-python-electionguard:ruby-3.1.1-node-16-python-3.8.11-electionguard-1.2.3 as python-wrapper-builder
LABEL author="hola@decidim.org"

# Add Makefile
# Add Makefiles
ADD Makefile /code/Makefile
ADD bulletin_board/server.mk /code/bulletin_board/server.mk
ADD bulletin_board/client.mk /code/bulletin_board/client.mk
ADD voting_schemes/dummy/makefile.mk /code/voting_schemes/dummy/makefile.mk
ADD voting_schemes/electionguard/makefile.mk /code/voting_schemes/electionguard/makefile.mk
ADD verifier/makefile.mk /code/verifier/makefile.mk

# Add the source files
ADD voting_schemes/electionguard/python-wrapper /code/voting_schemes/electionguard/python-wrapper
ADD voting_schemes/electionguard/makefile.mk /code/voting_schemes/electionguard/makefile.mk
ADD voting_schemes/dummy/makefile.mk /code/voting_schemes/dummy/makefile.mk
ADD verifier/makefile.mk /code/verifier/makefile.mk
ADD bulletin_board/client.mk /code/bulletin_board/client.mk
ADD bulletin_board/server.mk /code/bulletin_board/server.mk

# This step builds the electionguard-python package and the python wrapper
RUN cd /code && make build_electionguard_python_wrapper
@@ -51,13 +51,18 @@ ENV SECRET_KEY_BASE 1234
ENV RAILS_ENV production

# Install system dependencies
RUN apt-get update && \
RUN apt-get update --allow-releaseinfo-change && \
apt-get install -y postgresql postgresql-client postgresql-contrib libpq-dev \
redis-server memcached imagemagick ffmpeg mupdf mupdf-tools libxml2-dev curl && \
rm -rf /var/lib/apt/lists/*

# Add Makefile
# Add Makefiles
ADD Makefile /code/Makefile
ADD bulletin_board/server.mk /code/bulletin_board/server.mk
ADD bulletin_board/client.mk /code/bulletin_board/client.mk
ADD voting_schemes/dummy/makefile.mk /code/voting_schemes/dummy/makefile.mk
ADD voting_schemes/electionguard/makefile.mk /code/voting_schemes/electionguard/makefile.mk
ADD verifier/makefile.mk /code/verifier/makefile.mk

# Add local dependencies and copy some artifacts from previous stages
ADD bulletin_board/js-client /code/bulletin_board/js-client
@@ -68,11 +73,6 @@ COPY --from=python-to-js-builder /code/voting_schemes/electionguard /code/voting
ADD voting_schemes/electionguard/js-adapter /code/voting_schemes/electionguard/js-adapter
ADD voting_schemes/electionguard/ruby-adapter /code/voting_schemes/electionguard/ruby-adapter
COPY --from=python-to-js-builder /src/pyodide/build /code/voting_schemes/electionguard/ruby-adapter/public/assets/electionguard
ADD verifier/makefile.mk /code/verifier/makefile.mk
ADD voting_schemes/dummy/makefile.mk /code/voting_schemes/dummy/makefile.mk
ADD voting_schemes/electionguard/makefile.mk /code/voting_schemes/electionguard/makefile.mk
ADD bulletin_board/client.mk /code/bulletin_board/client.mk
ADD bulletin_board/server.mk /code/bulletin_board/server.mk

# Add dependencies manifests
ADD bulletin_board/server/package-lock.json /code/bulletin_board/server/package-lock.json
@@ -81,7 +81,7 @@ ADD bulletin_board/server/Gemfile.lock /code/bulletin_board/server/Gemfile.lock
ADD bulletin_board/server/Gemfile /code/bulletin_board/server/Gemfile

# Install all dependencies, build artifacts and remove unnecessary files
RUN cd /code && make install && make build && \
RUN cd /code && make install && make build SKIP_PYODIDE=true && \
rm -rf /code/bulletin_board/js-client && \
rm -rf /code/voting_schemes/dummy/js-adapter && \
rm -rf /code/voting_schemes/electionguard/js-adapter && \
@@ -96,7 +96,6 @@ RUN npm install --global yarn
RUN bundle
RUN bundle exec rake assets:precompile

# Run the entrypoint script
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["bundle", "exec", "sidekiq", "-C", "config/sidekiq.yml"]
2 changes: 1 addition & 1 deletion bulletin_board/server.mk
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ pre_release_server:
kill -9 $$(cat tmp/pids/development.pid) && rm tmp/pids/development.pid

release_server:
docker image build -t ${DOCKER_WEB_IMAGE} -f Dockerfile.web . && \
docker image build -t ${DOCKER_WEB_IMAGE} -f Dockerfile . && \
docker image push ${DOCKER_WEB_IMAGE}

bump_server:
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ Apart for the server stack, we will need to set up:

The Bulletin Board server is https://hub.docker.com/r/decidim/decidim-bulletin-board[published in Dockerhub] as a Docker container.

If you want to deploy a modified version of the Bulletin Board, we highly recommend to use `Dockerfile.web` in the root folder of the repository to build and release the application.
If you want to deploy a modified version of the Bulletin Board, we highly recommend to use `Dockerfile` in the root folder of the repository to build and release the application.

== ActiveStorage

2 changes: 1 addition & 1 deletion heroku.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
docker:
web: Dockerfile.web
web: Dockerfile
worker: Dockerfile.worker
release: Dockerfile.release

0 comments on commit 8d0de46

Please sign in to comment.