Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Project and Workflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Project and Workflow
Commits
08372d42
Commit
08372d42
authored
1 year ago
by
Rostislav Dublin (EPAM)
Browse files
Options
Downloads
Plain Diff
Merge branch 'pws-23' into 'main'
PWS-23: Service Dockerfile for development environment Closes
#23
See merge request
!3
parents
869737ca
16cdf389
No related branches found
No related tags found
1 merge request
!3
PWS-23: Service Dockerfile for development environment
Pipeline
#240794
passed
1 year ago
Stage: build
Stage: testing
Stage: deploy
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.dockerignore
+18
-0
18 additions, 0 deletions
.dockerignore
Dockerfile
+35
-0
35 additions, 0 deletions
Dockerfile
README.md
+7
-2
7 additions, 2 deletions
README.md
app/main.py
+12
-1
12 additions, 1 deletion
app/main.py
pyproject.toml
+3
-0
3 additions, 0 deletions
pyproject.toml
with
75 additions
and
3 deletions
.dockerignore
0 → 100644
+
18
−
0
View file @
08372d42
.env/
.venv/
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
pip-log.txt
pip-delete-this-directory.txt
.tox
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
*.log
.git*
This diff is collapsed.
Click to expand it.
Dockerfile
0 → 100644
+
35
−
0
View file @
08372d42
# The builder image, used to build the virtual environment
FROM
python:3.11-bullseye
as
builder
# Install package manager
RUN
pip
install
poetry
==
1.7.1
# Define environment
ENV
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
# Set work directory
WORKDIR
/app
# Copy project dependencies
COPY
pyproject.toml poetry.lock ./
# Install production dependencies only and remove poetry cache directory
RUN
poetry
install
--without
dev
--no-root
&&
rm
-rf
$POETRY_CACHE_DIR
# The runtime image, used to run the service
FROM
python:3.11-slim-bullseye
as
runtime
# Set virtual environment path and add it to the system Path
ENV
VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# Copy project dependencies from builder stage
COPY
--from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
# Copy project code
COPY
app ./app
# Run service
CMD
["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
This diff is collapsed.
Click to expand it.
README.md
+
7
−
2
View file @
08372d42
...
...
@@ -96,8 +96,8 @@ docker-compose up
curl localhost:8080/
```
#### Run with Dockerfile
```
#### Run with Dockerfile
[MacOS / Linux]
```
bash
export
BUILD_DATE
=
$(
date
-u
+
"%Y-%m-%dT%H:%M:%SZ"
)
export
COMMIT_ID
=
$(
git rev-parse HEAD
)
export
COMMIT_BRANCH
=
$(
git rev-parse
--abbrev-ref
HEAD
)
...
...
@@ -113,6 +113,11 @@ docker build -f "./Dockerfile" \
docker run pws:latest
```
#### Run with Dockerfile [Windows]
```
bash
winpty docker run
--rm
-it
-p
<container_port>:<host_port> pws
```
### Run with Uvicorn
```
...
...
This diff is collapsed.
Click to expand it.
app/main.py
+
12
−
1
View file @
08372d42
...
...
@@ -10,8 +10,19 @@ def create_app() -> FastAPI:
FastAPI: The configured and initialized FastAPI application.
"""
app
=
FastAPI
()
print
(
"
hello
"
)
return
app
application
=
create_app
()
app
=
create_app
()
@app.get
(
"
/
"
)
def
read_root
():
return
{
"
Hello
"
:
"
World
"
}
@app.get
(
"
/items/{item_id}
"
)
def
read_item
(
item_id
:
int
,
q
:
str
|
None
=
None
):
return
{
"
item_id
"
:
item_id
,
"
q
"
:
q
}
This diff is collapsed.
Click to expand it.
pyproject.toml
+
3
−
0
View file @
08372d42
...
...
@@ -4,6 +4,9 @@ version = "0.1.0"
description
=
""
authors
=
[
"Carlos Colin <Carlos_Colin@epam.com>"
]
readme
=
"README.md"
packages
=
[
{
include
=
"app"
}
]
[tool.poetry.dependencies]
python
=
"^3.11"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment