Skip to content

Commit

Permalink
feat: dockerized outline
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasPeters committed Sep 25, 2024
1 parent c00c95d commit bb21e70
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 86 deletions.
26 changes: 26 additions & 0 deletions .devcontainer/Dockerfile.website
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:latest
WORKDIR /home/plakplaats

# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libpq-dev gcc
RUN rm -rf /var/lib/apt/lists/*

# Install required python packages
COPY requirements.txt ./
RUN pip install -r requirements.txt --no-cache-dir

# Copy over remaining files
COPY . .

# Document which ports will be used
EXPOSE 3000

# Give a warm welcome
ENV SHELL="/bin/bash"
RUN echo "echo 'You are in the plakplaats devcontainer!'" >> /etc/bash.bashrc
RUN echo "echo 'Start the server with: python src/server.py'" >> /etc/bash.bashrc

# Do not run anything, but do not close the container either
CMD ["tail", "-f", "/dev/null"]
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Plakplaats devcontainer",
"workspaceFolder": "/home/plakplaats",
"dockerComposeFile": "docker-compose.yml",
"service": "website-dev",
"forwardPorts": [3000],
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-azuretools.vscode-docker"
]
}
},
"runServices": ["website-dev"]
}
14 changes: 14 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Inherit but overwrite production configs with development configs

include:
- path: ../docker-compose.yml

services:
website-dev:
build:
context: ..
dockerfile: .devcontainer/Dockerfile.website
ports:
- "3000:3000"
depends_on:
- postgres_db
84 changes: 1 addition & 83 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,88 +1,6 @@
.env

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

# .NET
obj/
bin/

# Ignore user uploads
uploads/

__pycache__
__pycache__
21 changes: 21 additions & 0 deletions Dockerfile.website
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:alpine
WORKDIR /home/plakplaats

# Install build dependencies
RUN apk add --no-cache postgresql-libs
RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev

# Copy the files responsible for listing dependencies
COPY requirements.txt ./

# Cache the python dependencies
RUN python3 -m pip install -r requirements.txt --no-cache-dir

# Remove previously installed build dependencies, they are not needed anymore
RUN apk del .build-deps

# Copy the source code
COPY src src

EXPOSE 3000
CMD ["python", "src/server.py"]
2 changes: 0 additions & 2 deletions dependencies.md

This file was deleted.

17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
website:
build:
dockerfile: Dockerfile.website
ports:
- "3000:3000"
depends_on:
- postgres_db

postgres_db:
image: postgres:latest
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: plakplaats-db
ports:
- "5432:5432"
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
flask
waitress
requests
psycopg2
python-dotenv
2 changes: 1 addition & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,4 @@ def checkFileName(name):
# only runs when executed as script, not when used as module
if __name__ == "__main__":
from waitress import serve
serve(app, host='0.0.0.0', port='7050')
serve(app, host='0.0.0.0', port='3000')

0 comments on commit bb21e70

Please sign in to comment.