Skip to content

Commit

Permalink
Refactor docker build to not use git checkout
Browse files Browse the repository at this point in the history
This fixes a persistent issue where non-master branch docker builds
would get master branch code.
  • Loading branch information
speshak committed Jun 13, 2020
1 parent e43f2e4 commit aec06ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
venv
node_modules
**/__pycache__
*.egg-info
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ target/
# IDE
.idea/

# External Libraries
# External Libraries
wger/core/static/bower_components
node_modules

venv
13 changes: 8 additions & 5 deletions extras/docker/apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Path to where misc docker files live, relative to the project root
ARG DOCKER_DIR=./extras/docker/apache


# Install dependencies
RUN apt-get update \
Expand All @@ -29,7 +32,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

# Configure apache
ADD wger.conf /etc/apache2/sites-available/
COPY ${DOCKER_DIR}/wger.conf /etc/apache2/sites-available/
RUN a2dissite 000-default.conf \
&& a2enmod headers \
&& a2ensite wger \
Expand All @@ -38,18 +41,18 @@ RUN a2dissite 000-default.conf \
&& usermod -G wger www-data

# Configure cron
ADD crontab /etc/cron.d/wger
ADD venvwrapper /home/wger/venvwrapper
COPY ${DOCKER_DIR}/crontab /etc/cron.d/wger
COPY ${DOCKER_DIR}/venvwrapper /home/wger/venvwrapper

RUN chmod 0644 /etc/cron.d/wger \
&& chmod +x /home/wger/venvwrapper \
&& touch /var/log/cron.log

COPY --chown=wger:www-data . /home/wger/src

# Set up the application
RUN ln -s /home/wger/static/CACHE /var/www
USER wger
RUN git clone -b ${SOURCE_BRANCH:-master} https://github.com/wger-project/wger.git /home/wger/src \
&& git -C /home/wger/src rev-parse HEAD

WORKDIR /home/wger/src
RUN virtualenv --python python3 /home/wger/venv
Expand Down

0 comments on commit aec06ea

Please sign in to comment.