-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77b46b9
commit bd61ecd
Showing
29 changed files
with
319 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# To remove all images, containers, networks: | ||
- command: `docker system prune -a -f` | ||
- documentation: https://docs.docker.com/engine/reference/commandline/system_prune/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM python:3.10.0-slim | ||
|
||
# Python commands run inside the virtual environment | ||
RUN python -m pip install \ | ||
pandas \ | ||
numpy \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Simple example | ||
|
||
## Install docker | ||
- https://docs.docker.com/get-docker/ | ||
|
||
## Post-installation | ||
- Make sure it works by running following command: | ||
- `docker run hello-world` | ||
|
||
## To run this docker file: | ||
- First run build command: `docker build -t example1 .` | ||
|
||
## Check that the image was built | ||
- `docker images` - can also see the file sizes | ||
|
||
- Then can run it: `docker run -it --rm example1` | ||
- (-it) keeps the container running | ||
- (--rm) automatically removes the container when exiting the program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM ubuntu:18.04 | ||
|
||
## add some labels | ||
LABEL maintainer="[email protected]" | ||
LABEL version="0.1" | ||
LABEL description="This is a Dockerfile for a simple Ubuntu container." | ||
|
||
## update the container | ||
RUN apt-get update && apt-get upgrade -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Build (make sure you are in the right directory) | ||
- `docker build -t ubuntu .` | ||
|
||
# Run | ||
- `docker run -i -d --rm ubuntu` | ||
- note, the -d stands for 'detached' - meaning that this will run in the background | ||
- if we want to see what is running in the background, we can do: `docker ps` to see list of containers running | ||
- if we want to jummp into the terminal of the running container: | ||
- `docker exec -it 408f95b22bcf /bin/bash` - will run/execute a command, bringing up the /bash terminal for us |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Create MySQL Image for JSP Tutorial Application | ||
FROM mysql:latest | ||
|
||
ENV MYSQL_ROOT_PASSWORD ahi2020 | ||
|
||
EXPOSE 3306 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Build | ||
- `docker build -t hants-sql .` | ||
|
||
# Run | ||
- `docker run -d -p 3305:3306 hants-sql` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## https://docs.streamlit.io/knowledge-base/tutorials/deploy/docker | ||
|
||
FROM python:3.9-slim | ||
|
||
EXPOSE 8501 | ||
|
||
# Set working directory in the container | ||
WORKDIR /app | ||
|
||
# copy /app directory from local machine to /app directory in container | ||
COPY /app /app | ||
|
||
# install dependencies and updates | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
software-properties-common \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# install python dependencies for python | ||
RUN pip3 install -r requirements.txt | ||
|
||
# run the app | ||
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
altair | ||
pandas | ||
streamlit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from collections import namedtuple | ||
import altair as alt | ||
import math | ||
import pandas as pd | ||
import streamlit as st | ||
|
||
""" | ||
# Welcome to Streamlit (by hants)! | ||
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart: | ||
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community | ||
forums](https://discuss.streamlit.io). | ||
In the meantime, below is an example of what you can do with just a few lines of code: | ||
""" | ||
|
||
with st.echo(code_location='below'): | ||
total_points = st.slider("Number of points in spiral", 1, 5000, 2000) | ||
num_turns = st.slider("Number of turns in spiral", 1, 100, 9) | ||
|
||
Point = namedtuple('Point', 'x y') | ||
data = [] | ||
|
||
points_per_turn = total_points / num_turns | ||
|
||
for curr_point_num in range(total_points): | ||
curr_turn, i = divmod(curr_point_num, points_per_turn) | ||
angle = (curr_turn + 1) * 2 * math.pi * i / points_per_turn | ||
radius = curr_point_num / total_points | ||
x = radius * math.cos(angle) | ||
y = radius * math.sin(angle) | ||
data.append(Point(x, y)) | ||
|
||
st.altair_chart(alt.Chart(pd.DataFrame(data), height=500, width=500) | ||
.mark_circle(color='#0068c9', opacity=0.5) | ||
.encode(x='x:Q', y='y:Q')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Build | ||
- `docker build -t streamlit .` | ||
|
||
# Run: | ||
- `docker run -p 8501:8501 streamlit` | ||
- note - the -p is for opening up the containers port 8501 and pushing it to our machines/OS port 8501 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM python:3.7-alpine | ||
## add bash so can use bash commands/go into container | ||
RUN apk update && apk add bash | ||
|
||
# set working directory with env varialbes | ||
WORKDIR /code | ||
ENV FLASK_APP=app.py | ||
ENV FLASK_RUN_HOST=0.0.0.0 | ||
ENV FLASK_DEBUG=1 | ||
ENV FLASK_RUN_PORT=5001 | ||
|
||
# copy files into working directory | ||
COPY . . | ||
|
||
# install dependencies | ||
RUN pip install -r requirements.txt | ||
|
||
# run the app and expose the default port for flask | ||
EXPOSE 5001 | ||
CMD ["flask", "run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def hello(): | ||
return 'Hello World! This is from a basic flask app - with mods (part3)' |
1 change: 1 addition & 0 deletions
1
containers/docker_w_compose_ex1_flask_1app/app/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
flask |
8 changes: 8 additions & 0 deletions
8
containers/docker_w_compose_ex1_flask_1app/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: "3.9" | ||
services: | ||
flaskapp1: | ||
build: ./app | ||
ports: | ||
- "8001:5001" | ||
volumes: | ||
- ./app:/code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# To run: | ||
- `docker-compose up --build` | ||
- this will build the container and everything in it for the first time | ||
|
||
## To run again with no changes: | ||
- `docker-compose up` | ||
- while if you need to update it because of code changes to the docker file, likely should add `--build` argument to end |
20 changes: 20 additions & 0 deletions
20
containers/docker_w_compose_ex1_flask_3app/app1/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM python:3.7-alpine | ||
## add bash so can use bash commands/go into container | ||
RUN apk update && apk add bash | ||
|
||
# set working directory with env varialbes | ||
WORKDIR /code | ||
ENV FLASK_APP=app.py | ||
ENV FLASK_RUN_HOST=0.0.0.0 | ||
ENV FLASK_DEBUG=1 | ||
ENV FLASK_RUN_PORT=5001 | ||
|
||
# copy files into working directory | ||
COPY . . | ||
|
||
# install dependencies | ||
RUN pip install -r requirements.txt | ||
|
||
# run the app and expose the default port for flask | ||
EXPOSE 5001 | ||
CMD ["flask", "run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def hello(): | ||
return 'Hello from Flask App 1' |
1 change: 1 addition & 0 deletions
1
containers/docker_w_compose_ex1_flask_3app/app1/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
flask |
20 changes: 20 additions & 0 deletions
20
containers/docker_w_compose_ex1_flask_3app/app2/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM python:3.7-alpine | ||
## add bash so can use bash commands/go into container | ||
RUN apk update && apk add bash | ||
|
||
# set working directory with env varialbes | ||
WORKDIR /code | ||
ENV FLASK_APP=app.py | ||
ENV FLASK_RUN_HOST=0.0.0.0 | ||
ENV FLASK_DEBUG=1 | ||
ENV FLASK_RUN_PORT=5002 | ||
|
||
# copy files into working directory | ||
COPY . . | ||
|
||
# install dependencies | ||
RUN pip install -r requirements.txt | ||
|
||
# run the app and expose the default port for flask | ||
EXPOSE 5002 | ||
CMD ["flask", "run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def hello(): | ||
return 'Hell from Flask App 2' |
1 change: 1 addition & 0 deletions
1
containers/docker_w_compose_ex1_flask_3app/app2/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
flask |
24 changes: 24 additions & 0 deletions
24
containers/docker_w_compose_ex1_flask_3app/app3/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## https://docs.streamlit.io/knowledge-base/tutorials/deploy/docker | ||
|
||
FROM python:3.9-slim | ||
|
||
EXPOSE 8501 | ||
|
||
# Set working directory in the container | ||
WORKDIR /app | ||
|
||
# copy /app directory from local machine to /app directory in container | ||
COPY /app /app | ||
|
||
# install dependencies and updates | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
software-properties-common \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# install python dependencies for python | ||
RUN pip3 install -r requirements.txt | ||
|
||
# run the app | ||
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"] |
3 changes: 3 additions & 0 deletions
3
containers/docker_w_compose_ex1_flask_3app/app3/app/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
altair | ||
pandas | ||
streamlit |
37 changes: 37 additions & 0 deletions
37
containers/docker_w_compose_ex1_flask_3app/app3/app/streamlit_app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from collections import namedtuple | ||
import altair as alt | ||
import math | ||
import pandas as pd | ||
import streamlit as st | ||
|
||
""" | ||
# Welcome to Streamlit (by hants)! | ||
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart: | ||
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community | ||
forums](https://discuss.streamlit.io). | ||
In the meantime, below is an example of what you can do with just a few lines of code: | ||
""" | ||
|
||
with st.echo(code_location='below'): | ||
total_points = st.slider("Number of points in spiral", 1, 5000, 2000) | ||
num_turns = st.slider("Number of turns in spiral", 1, 100, 9) | ||
|
||
Point = namedtuple('Point', 'x y') | ||
data = [] | ||
|
||
points_per_turn = total_points / num_turns | ||
|
||
for curr_point_num in range(total_points): | ||
curr_turn, i = divmod(curr_point_num, points_per_turn) | ||
angle = (curr_turn + 1) * 2 * math.pi * i / points_per_turn | ||
radius = curr_point_num / total_points | ||
x = radius * math.cos(angle) | ||
y = radius * math.sin(angle) | ||
data.append(Point(x, y)) | ||
|
||
st.altair_chart(alt.Chart(pd.DataFrame(data), height=500, width=500) | ||
.mark_circle(color='#0068c9', opacity=0.5) | ||
.encode(x='x:Q', y='y:Q')) |
21 changes: 21 additions & 0 deletions
21
containers/docker_w_compose_ex1_flask_3app/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: "3.9" | ||
services: | ||
app1_flask: | ||
build: ./app1 | ||
ports: | ||
- "8001:5001" | ||
volumes: | ||
- ./app1:/code | ||
app2_flask: | ||
build: ./app2 | ||
ports: | ||
- "8002:5002" | ||
volumes: | ||
- ./app2:/code | ||
app3_streamlit: | ||
build: ./app3 | ||
ports: | ||
- "8003:8501" | ||
volumes: | ||
- ./app3/app:/app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# To run: | ||
- `docker-compose up --build` | ||
- this will build the container and everything in it for the first time | ||
|
||
## To run again with no changes: | ||
- `docker-compose up` | ||
- while if you need to update it because of code changes to the docker file, likely should add `--build` argument to end |
Empty file.