From c198af67668d91416b49b034b51a8f10ac4e4684 Mon Sep 17 00:00:00 2001 From: Yosef Bedaso Date: Wed, 20 Mar 2024 22:04:04 -0700 Subject: [PATCH] adds script to publish docker image --- .dockerignore | 23 ++++++++++++++++++++++ .github/workflows/publish.yaml | 36 ++++++++++++++++++++++++++++++++++ .gitignore | 4 +++- Dockerfile | 21 ++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/publish.yaml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2c87e31 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +env +pip-log.txt +pip-delete-this-directory.txt +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.git +.mypy_cache +.pytest_cache +.hypothesis +.venv +venv +.streamlit/secrets.* diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..9823e30 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,36 @@ +name: Tag and publish +on: + push: + branches: + - main +jobs: + tag: + uses: AllenNeuralDynamics/aind-github-actions/.github/workflows/tag.yml@main + secrets: + SERVICE_TOKEN: ${{ secrets.SERVICE_TOKEN }} # required + + publish: + runs-on: ubuntu-latest + needs: tag + steps: + - uses: actions/checkout@v3 + - name: Pull latest changes + run: git pull origin main + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Github Packages + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build image and push to GitHub Container Registry + uses: docker/build-push-action@v3 + with: + # relative path to the place where source code with Dockerfile is located + context: . + push: true + tags: | + ghcr.io/allenneuraldynamics/foraging-behavior-browser-test:${{ needs.tag.outputs.new_version }} + ghcr.io/allenneuraldynamics/foraging-behavior-browser-test:latest diff --git a/.gitignore b/.gitignore index 08d4b89..0b16454 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ secrets* curriculum_manager .streamlit/secrets.toml -*.pyc \ No newline at end of file +*.pyc +.venv +venv diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7f5395a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.8-slim + +WORKDIR /app + +COPY . . + +RUN apt-get update +RUN apt-get install -y \ + git \ + build-essential \ + curl \ + software-properties-common \ + && rm -rf /var/lib/apt/lists/* + +RUN pip3 install -r requirements.txt --no-cache-dir + +EXPOSE 8501 + +HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health + +ENTRYPOINT ["streamlit", "run", "code/Home.py", "--server.port=8501", "--server.address=0.0.0.0"] \ No newline at end of file