Skip to content

Commit

Permalink
feat(packaging): various changes to be able to package the nuxt app i…
Browse files Browse the repository at this point in the history
…nto a static site
  • Loading branch information
hutchic committed Jul 19, 2024
1 parent 4609c46 commit 7b59c18
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 143 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.nuxt
dist
.DS_Store
.env
.env.local
.env.*.local
143 changes: 6 additions & 137 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
1 change: 1 addition & 0 deletions app/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
context: .
args:
NODE_ENV: development
container_name: nuxt_app
volumes:
- ./app/:/src
- /src/node_modules
Expand Down
10 changes: 10 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# Default command
cmd="npm run dev"

if [ "$1" = "generate" ]; then
cmd="npm run generate"
fi

exec $cmd

0 comments on commit 7b59c18

Please sign in to comment.