diff --git a/Dockerfile-build-branch b/Dockerfile-build-branch new file mode 100644 index 0000000..d1ec2be --- /dev/null +++ b/Dockerfile-build-branch @@ -0,0 +1,93 @@ +# docker build --file Dockerfile-build-branch \ +# --build-arg SSH_KEY="$(cat ~/.ssh/id_rsa)" \ +# --build-arg REPO="git@github.com:liquidvotingio/decidim.git" \ +# --build-arg BRANCH="stateless-app-generator" \ +# -t decidim-staging . + +# Git repo checkout builder +# based on https://github.com/jnovack/git-checkout +FROM alpine:latest as repo-builder + +WORKDIR /repo + +ARG SSH_KEY +ENV SSH_KEY=$SSH_KEY +ARG REPO="git@github.com:decidim/decidim.git" +ENV REPO=$REPO +ARG BRANCH="develop" +ENV BRANCH=$BRANCH +ENV HASH="HEAD" + +RUN apk add --no-cache git openssh + +ENV USER=appuser +ENV UID=10001 +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/home/${USER}" \ + --shell "/sbin/nologin" \ + --uid "${UID}" \ + "${USER}" +RUN chown -R appuser:appuser /repo +USER appuser:appuser + +RUN /bin/mkdir -p ~/.ssh \ + && /bin/echo "[DEBUG] Copying ssh private key from environment ..." \ + && /bin/echo -e "$SSH_KEY" > ~/.ssh/id_rsa \ + && /bin/echo "[DEBUG] Using ~/.ssh/id_rsa ..." \ + && /bin/chmod 400 ~/.ssh/id_rsa \ + && eval $(ssh-agent -s) > /dev/null \ + && /usr/bin/ssh-add ~/.ssh/id_rsa + +RUN /bin/echo -e "Host * \n StrictHostKeyChecking no" > ~/.ssh/config + +RUN /bin/echo "[INFO ] Downloading from ${REPO} ..." \ + && /bin/echo "[INFO ] ... checking out ${BRANCH}" \ + && /bin/echo "[INFO ] ... resetting to ${HASH}" + +RUN /bin/echo "[INFO ] Creating new repository ..." \ + && /bin/rm -rf * &> /dev/null || /bin/true \ + && /bin/rm -rf .* &> /dev/null || /bin/true \ + && /usr/bin/git clone -b "$BRANCH" \ + --single-branch "$REPO" . + + # && /usr/bin/git remote add origin "$REPO" \ + # && /usr/bin/git fetch origin \ + # && /usr/bin/git checkout --force "$BRANCH" \ + # && /usr/bin/git reset --hard "$HASH" \ + +## Gem builder +# ARG ruby_version=2.7.1 +FROM ruby:2.7.1 + +COPY --from=repo-builder /repo /repo + +WORKDIR /repo + +ENV LANG C.UTF-8 +ENV LC_ALL C.UTF-8 + +RUN apt-get install -y git imagemagick wget \ + && apt-get clean + +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \ + && apt-get install -y nodejs \ + && apt-get clean + +RUN npm install -g npm@6.3.0 + +RUN gem install bundler --version '>= 2.1.4' + +RUN bundle install + +# Not yet available on decidim/decidim - will be submitted soon +RUN bundle exec rake decidim:generate_stateless_demo_app + +# Before this can be run, there'll need to be a docker exec to run migrations +# and seeding through rake. This of course can only be done once container is up +# and running and with access to a database. +CMD ["bundle", "exec", "rails", "s", "-b", "0.0.0.0"] + +# So far trying to avoid using an entrypoint script +ENTRYPOINT []