Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shru #98

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Shru #98

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion day-14/simple-python-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY requirements.txt .
# Install the project dependencies
RUN pip install -r requirements.txt

# Copy the application code into the container
# Copy the applications code into the container
COPY . .

# Expose the port the Flask application will be listening on
Expand Down
3 changes: 2 additions & 1 deletion day-14/simple-python-app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ def hello():
return 'Hello, world!'

if __name__ == '__main__':
app.run()
app.run()


23 changes: 23 additions & 0 deletions sample-deploy/sample-python-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Base image
FROM python:3.8

# Set the working directory inside the container
WORKDIR /app

# Copy the requirements file
COPY requirements.txt .

# Install the project dependencies
RUN pip install -r requirements.txt

# Copy the applications code into the container
COPY . .

# Expose the port the Flask application will be listening on
EXPOSE 5000

# Set environment variables, if necessary
# ENV MY_ENV_VAR=value

# Run the Flask application
CMD ["python", "app.py"]
11 changes: 11 additions & 0 deletions sample-deploy/sample-python-app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
return 'Hello, world!'

if __name__ == '__main__':
app.run()

26 changes: 26 additions & 0 deletions sample-deploy/sample-python-app/buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 0.2

env:
parameter-store:
DOCKER_REGISTRY_USERNAME: /mysampleapp/docker-credentials/username
DOCKER_REGISTRY_PASSWORD: /mysampleapp/docker-credentials/password
DOCKER_REGISTRY_URL: /mysampleapp/docker-registry/url
phases:
install:
runtime-versions:
python: 3.11
pre_build:
commands:
- echo "Installing dependencies..."
- pip install -r sample-deploy/sample-python-app/requirements.txt
build:
commands:
- cd sample-deploy/sample-python-app
- echo "Building Docker image..."
- echo "$DOCKER_REGISTRY_PASSWORD" | docker login -u "$DOCKER_REGISTRY_USERNAME" --password-stdin "$DOCKER_REGISTRY_URL"
- docker build -t "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/sample-python-flask-app100:latest" .
- docker push "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/sample-python-flask-app100:latest"
post_build:
commands:
- echo "Build completed successfully!"

1 change: 1 addition & 0 deletions sample-deploy/sample-python-app/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flask
4 changes: 2 additions & 2 deletions scripts/start_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

# Pull the Docker image from Docker Hub
docker pull abhishekf5/simple-python-flask-app
docker pull hariknag/sample-python-flask-app100

# Run the Docker image as a container
docker run -d -p 5000:5000 abhishekf5/simple-python-flask-app
docker run -d -p 5000:5000 hariknag/sample-python-flask-app100