From 56d00d397364b9d71565d8ddd790c77b4b5e1f5a Mon Sep 17 00:00:00 2001 From: Daya Adianto Date: Thu, 31 Aug 2023 14:54:17 +0700 Subject: [PATCH] Create Dockerfile This commit introduces a basic container-based runtime by adding a Dockerfile. Related issue: #5 --- .dockerignore | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ .editorconfig | 12 ++++++++ .gitignore | 2 +- .python-version | 2 +- Dockerfile | 27 +++++++++++++++++ Procfile | 3 +- README.en.md | 6 ++-- README.md | 8 ++--- runtime.txt | 2 +- 9 files changed, 128 insertions(+), 12 deletions(-) create mode 100644 .dockerignore create mode 100644 .editorconfig create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..311b9b9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,78 @@ +# Virtual environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Python cache files +__pycache__/ + +# SQLite database +db.sqlite3 +db.sqlite3-journal + +# User-uploaded media +media + +# Collected static files +staticfiles/ + +# Coverage +.coverage +.coverage.* +coverage.* +htmlcov/ + +# Chromedriver +chromedriver +chromedriver.exe + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows shortcuts +*.lnk diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..69fbfa8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.yml] +indent_size = 2 diff --git a/.gitignore b/.gitignore index 79c4c76..311b9b9 100644 --- a/.gitignore +++ b/.gitignore @@ -75,4 +75,4 @@ ehthumbs_vista.db $RECYCLE.BIN/ # Windows shortcuts -*.lnk \ No newline at end of file +*.lnk diff --git a/.python-version b/.python-version index 14fc9e9..9ac3804 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.10.6 \ No newline at end of file +3.11.5 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..42c596f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Use official Python container image +FROM docker.io/library/python:3.11.5-alpine + +# Configure environment variables +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONBUFFERED=1 + +# TODO: Configure environment variables required by Django project +# e.g., database connection, parameterised configuration in settings.py + +# Set the active working directory in the container +WORKDIR /app + +# Copy the requirements file into the container +COPY requirements.txt . + +# Install the declared app dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the source code files into the container +COPY . . + +# Expose the port that the app will run on +EXPOSE 8000 + +# Run the app +CMD ["/bin/sh", "-c", "python manage.py migrate && gunicorn project_django.wsgi --log-file -"] diff --git a/Procfile b/Procfile index 10c02ca..2827aec 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1 @@ -release: python manage.py migrate -web: gunicorn project_django.wsgi --log-file - \ No newline at end of file +web: python manage.py migrate && gunicorn project_django.wsgi --log-file - diff --git a/README.en.md b/README.en.md index 58bf3bd..ee3590d 100644 --- a/README.en.md +++ b/README.en.md @@ -1,6 +1,6 @@ # PBP Django Project Template -Platform-Based Programming (CSGE602022) - Organized by the Faculty of Computer Science Universitas Indonesia, Odd Semester 2022/2023 +Platform-Based Programming (CSGE602022) - Organized by the Faculty of Computer Science Universitas Indonesia, Odd Semester 2023/2024 *Read this in other languages: [Indonesian](README.md), [English](README.en.md)* @@ -85,7 +85,7 @@ code template repository can be found at: https://django-pbp-template.herokuapp. If you have successfully created your own repository and set up the Django Web application project, you can start working on the weekly tutorials and assignments -related to Django Web application development. +related to Django Web application development. If you found any issues or have ideas to improve the code template, feel free to discuss your proposal via the [issue tracker](https://github.com/pbp-fasilkom-ui/django-pbp-template/issues) @@ -98,4 +98,4 @@ This template was based on [PBP Odd Term 2021/2022](https://gitlab.com/PBP-2021/ [Heroku]: https://www.heroku.com/ [Tutorial 0]: https://pbp-fasilkom-ui.github.io/ganjil-2023/en/assignments/tutorial/tutorial-0 [Visual Studio Code]: https://code.visualstudio.com/ -[PyCharm]: https://www.jetbrains.com/pycharm/ \ No newline at end of file +[PyCharm]: https://www.jetbrains.com/pycharm/ diff --git a/README.md b/README.md index 99b4cd8..40a661e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Template Proyek Django PBP -Pemrograman Berbasis Platform (CSGE602022) - diselenggarakan oleh Fakultas Ilmu Komputer Universitas Indonesia, Semester Ganjil 2022/2023 +Pemrograman Berbasis Platform (CSGE602022) - diselenggarakan oleh Fakultas Ilmu Komputer Universitas Indonesia, Semester Ganjil 2023/2024 *Read this in other languages: [Indonesian](README.md), [English](README.en.md)* @@ -49,9 +49,9 @@ Apabila kamu ingin menggunakan repositori ini sebagai repositori awalan yang nan ``` 7. Bukalah `http://localhost:8000` pada browser favoritmu untuk melihat apakah aplikasi sudah berjalan dengan benar. -## Contoh Deployment +## Contoh Deployment -Pada template ini, deployment dilakukan dengan memanfaatkan GitHub Actions sebagai _runner_ dan Heroku sebagai platform Hosting aplikasi. +Pada template ini, deployment dilakukan dengan memanfaatkan GitHub Actions sebagai _runner_ dan Heroku sebagai platform Hosting aplikasi. Untuk melakukan deployment, kamu dapat melihat instruksi yang ada pada [Tutorial 0](https://pbp-fasilkom-ui.github.io/ganjil-2023/assignments/tutorial/tutorial-0). @@ -59,4 +59,4 @@ Untuk contoh aplikasi Django yang sudah di deploy, dapat kamu akses di [https:// ## Credits -Template ini dibuat berdasarkan [PBP Ganjil 2021](https://gitlab.com/PBP-2021/pbp-lab) yang ditulis oleh Tim Pengajar Pemrograman Berbasis Platform 2021 ([@prakashdivyy](https://gitlab.com/prakashdivyy)) dan [django-template-heroku](https://github.com/laymonage/django-template-heroku) yang ditulis oleh [@laymonage, et al.](https://github.com/laymonage). Template ini dirancang sedemikian rupa sehingga mahasiswa dapat menjadikan template ini sebagai awalan serta acuan dalam mengerjakan tugas maupun dalam berkarya. \ No newline at end of file +Template ini dibuat berdasarkan [PBP Ganjil 2021](https://gitlab.com/PBP-2021/pbp-lab) yang ditulis oleh Tim Pengajar Pemrograman Berbasis Platform 2021 ([@prakashdivyy](https://gitlab.com/prakashdivyy)) dan [django-template-heroku](https://github.com/laymonage/django-template-heroku) yang ditulis oleh [@laymonage, et al.](https://github.com/laymonage). Template ini dirancang sedemikian rupa sehingga mahasiswa dapat menjadikan template ini sebagai awalan serta acuan dalam mengerjakan tugas maupun dalam berkarya. diff --git a/runtime.txt b/runtime.txt index ee92de7..3124d55 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.10.6 \ No newline at end of file +python-3.11.5