diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..99a864b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules +.nuxt +dist +.DS_Store +.env +.env.local +.env.*.local diff --git a/.gitignore b/.gitignore index a81c8ee..99a864b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,138 +1,7 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments +node_modules +.nuxt +dist +.DS_Store .env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ +.env.local +.env.*.local diff --git a/Dockerfile b/Dockerfile index 58c3306..b4d474c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,11 @@ WORKDIR /src COPY app/package.json app/package-lock.json ./ RUN npm install -# Copy project files -COPY app/ . +# Copy project files and set permissions +COPY --chown=node:node app/ . + +# Change to non-root user +USER node # Expose port 3000 EXPOSE 3000 diff --git a/Makefile b/Makefile index 3eebe6d..3f8e6f2 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,18 @@ -.PHONY: build dev logs clean +.PHONY: build dev logs clean package stop restart exec # Build the Docker images build: - docker compose build + UID=$$(id -u) GID=$$(id -g) docker compose build # Start the development environment -dev: - docker compose up -d +dev: build + UID=$$(id -u) GID=$$(id -g) docker compose up -d +# Stop the development environment stop: docker compose stop +# Restart the development environment restart: docker compose restart @@ -27,3 +29,9 @@ clean: docker compose down -v --rmi all --remove-orphans rm -rf node_modules rm -rf .nuxt + rm -rf app/dist + +# Generate the static site +package: clean + docker compose up -d nuxt + docker compose exec nuxt npm run generate diff --git a/app/nuxt.config.ts b/app/nuxt.config.ts index c654df5..17b6b2d 100644 --- a/app/nuxt.config.ts +++ b/app/nuxt.config.ts @@ -1,5 +1,6 @@ // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ + ssr: false, devtools: { enabled: true }, modules: ["@nuxt/ui", "@vite-pwa/nuxt", "nuxt-vue3-google-signin"], googleSignIn: { diff --git a/docker-compose.yml b/docker-compose.yml index b977665..9cacf8d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: context: . args: NODE_ENV: development + container_name: nuxt_app volumes: - ./app/:/src - /src/node_modules diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..542c11e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Default command +cmd="npm run dev" + +if [ "$1" = "generate" ]; then + cmd="npm run generate" +fi + +exec $cmd