Skip to content

Commit

Permalink
use poetry in docker image build
Browse files Browse the repository at this point in the history
  • Loading branch information
anik3tra0 committed Jan 24, 2024
1 parent 282988b commit 7b3aaab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
29 changes: 20 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Install cron
RUN apt-get update && apt-get -y install cron

# Set the working directory in the container to /app
WORKDIR /app

# Copy the Python script into the container at /app
COPY ecs_service_discovery.py /app/

# Install any needed packages specified in requirements.txt
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
# Install Poetry
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python \
&& ln -s $HOME/.poetry/bin/poetry /usr/local/bin/poetry \
&& apt-get remove -y curl \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get -f install cron

# Copy the Python script and poetry files (pyproject.toml, poetry.lock) into the container at /app
COPY main.py pyproject.toml poetry.lock crontab /app/

# Install project dependencies
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi

### Enable this if you want to run this as a one off process
## Run ecs_service_discovery.py when the container launches
#CMD ["python", "./main.py"]

# Add crontab file in the cron directory
ADD crontab /etc/cron.d/ecs-service-discovery-cron
Expand Down
2 changes: 1 addition & 1 deletion crontab
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Run ecs_service_discovery.py every 3 minutes
*/3 * * * * python /app/ecs_service_discovery.py >> /var/log/cron.log 2>&1
*/3 * * * * python /app/main.py >> /var/log/cron.log 2>&1

# An empty line is required at the end of this file for a valid cron file.

0 comments on commit 7b3aaab

Please sign in to comment.