Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Ebooko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TheJoeCoder
Ebooko
Commits
3801ed57
Commit
3801ed57
authored
7 months ago
by
TheJoeCoder
Browse files
Options
Downloads
Patches
Plain Diff
Create Dockerfile
parent
0e337445
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Dockerfile
+66
-0
66 additions, 0 deletions
Dockerfile
with
66 additions
and
0 deletions
Dockerfile
0 → 100644
+
66
−
0
View file @
3801ed57
## Builder ##
# Pull image
FROM
python:3.12-slim-bookworm
AS
builder
# Set working dir to app directory
WORKDIR
/usr/src/app
# Set env variables
ENV
PYTHONDONTWRITEBYTECODE 1
ENV
PYTHONUNBUFFERED 1
# Dependencies
RUN
apt-get update
&&
\
apt-get install -y --no-install-recommends gcc
# Install python requirements
COPY
./requirements.txt .
COPY
./requirements.prod.txt .
RUN
pip wheel
--no-cache-dir
--wheel-dir
/usr/src/app/wheels
-r
requirements.txt
RUN
pip wheel
--no-cache-dir
--wheel-dir
/usr/src/app/wheels
-r
requirements.prod.txt
## Final image ##
# Pull image
FROM
python:3.12-slim-bookworm
# App user dir
RUN
mkdir
-p
/home/app
# App user
RUN
addgroup
--system
app
&&
adduser
--system
--group
app
# Create directories
ENV
HOME=/home/app
ENV
APP_HOME=/home/app/web
RUN
mkdir
$APP_HOME
RUN
mkdir
$APP_HOME
/staticfiles
RUN
mkdir
$APP_HOME
/mediafiles
WORKDIR
$APP_HOME
ENV
DJANGO_SETTINGS_MODULE=local_settings_prod
# Install requirements
RUN
apt-get update
&&
apt-get
install
-y
--no-install-recommends
netcat-openbsd
COPY
--from=builder /usr/src/app/wheels /wheels
COPY
--from=builder /usr/src/app/requirements.txt .
COPY
--from=builder /usr/src/app/requirements.prod.txt .
RUN
pip
install
--upgrade
pip
RUN
pip
install
--no-cache
/wheels/
*
# copy entrypoint.sh
COPY
./entrypoint.sh .
RUN
sed
-i
's/\r$//g'
$APP_HOME
/entrypoint.sh
RUN
chmod
+x
$APP_HOME
/entrypoint.sh
# copy project
COPY
. $APP_HOME
# chown all the files to the app user
RUN
chown
-R
app:app
$APP_HOME
# change to the app user
USER
app
# run entrypoint.sh
ENTRYPOINT
["/home/app/web/entrypoint.sh"]
This diff is collapsed.
Click to expand it.
TheJoeCoder
@TheJoeCoder
mentioned in commit
9f8531d4
·
7 months ago
mentioned in commit
9f8531d4
mentioned in commit 9f8531d460bcd086f217d54676a632c3f7f4658e
Toggle commit list
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
sign in
to comment