-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da2ef9c
commit 2a4d96b
Showing
3 changed files
with
62 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
LICENSE | ||
README.md | ||
sonar-project.properties | ||
setup.py | ||
.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,59 @@ | ||
FROM python:alpine | ||
# Use an official Python runtime as a parent image | ||
FROM python:alpine AS base | ||
|
||
ARG PORT=7777 | ||
ARG HOST='0.0.0.0' | ||
# Set up a non-root user and working directory | ||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup | ||
USER appuser | ||
WORKDIR /app | ||
|
||
ENV PORT=$PORT | ||
ENV HOST=$HOST | ||
# Copy only the necessary files for dependency installation | ||
COPY requirements.txt . | ||
|
||
COPY . /heyptt | ||
# Install any needed packages specified in requirements.txt | ||
RUN pip install --trusted-host pypi.python.org -r requirements.txt --no-cache-dir | ||
|
||
WORKDIR /heyptt | ||
# Use multistage build to create a separate build stage | ||
FROM base AS builder | ||
|
||
RUN pip3 install -r ./requirements.txt --upgrade --no-cache-dir | ||
# Copy the rest of the application code | ||
COPY --chown=appuser:appgroup . . | ||
|
||
EXPOSE $PORT | ||
# New stage for building the web assets | ||
FROM node:lts-alpine AS web_builder | ||
|
||
CMD ["python3", "serve.py"] | ||
# Initialize pnpm globally | ||
RUN corepack enable | ||
|
||
# Set up a non-root user and working directory for the web project | ||
RUN addgroup -S webgroup && adduser -S webuser -G webgroup | ||
USER webuser | ||
WORKDIR /web | ||
|
||
# Copy the package.json and pnpm-lock.yaml files for dependency installation | ||
COPY --chown=webuser:webgroup web/package.json web/pnpm-lock.yaml ./ | ||
|
||
# Install the web project dependencies | ||
RUN pnpm install --frozen-lockfile | ||
|
||
# Copy the rest of the web project files | ||
COPY --chown=webuser:webgroup web/ . | ||
|
||
# Build the web project | ||
RUN pnpm build | ||
|
||
# Switch back to the base image | ||
FROM base | ||
|
||
# Copy the compiled application from the builder stage | ||
COPY --from=builder --chown=appuser:appgroup /app /app | ||
|
||
# Copy the built web assets to /website | ||
COPY --from=web_builder --chown=appuser:appgroup /web/dist /app/website | ||
|
||
# Set the environment variables | ||
ENV PORT=${PORT} | ||
ENV HOST=${HOST:-0.0.0.0} | ||
|
||
# Make the container executable and run the application | ||
ENTRYPOINT ["python3"] | ||
CMD ["serve.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
version: '3' | ||
|
||
services: | ||
heyptt: | ||
hey-ptt: | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
image: hey-ptt | ||
ports: | ||
- '7777:7777' | ||
environment: | ||
- PORT=7777 | ||
- HOST=0.0.0.0 | ||
restart: unless-stopped |