Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from Yarn to NPM #2289

Merged
merged 1 commit into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ htmlcov

# dir for collected static files
staticfiles/*
# JS, CSS dependencies (installed via yarn)
# JS, CSS dependencies
node_modules/*
# dir for media (uploaded by users) files
mediafiles/*
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ jobs:
python -m pip install pipenv
pipenv sync --dev

- name: Install Yarn
run: npm install -g yarn

- name: Install NodeJS dependencies
run: yarn install
run: npm install

- name: Check migrations
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ htmlcov

# dir for collected static files
staticfiles/*
# JS, CSS dependencies (installed via yarn)
# JS, CSS dependencies
node_modules
# dir for media (uploaded by users) files
mediafiles/*
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ dev_database :
${MANAGE} fake_database
${MANAGE} createinitialrevisions

## node_modules : install front-end dependencies using Yarn
## node_modules : install front-end dependencies
node_modules : package.json
yarn install --frozen-lockfile
npm install
touch node_modules

## serve : run a server
Expand All @@ -48,7 +48,7 @@ serve :
## outdated : show outdated dependencies
outdated :
-${PYTHON} -m pip list --outdated
-yarn outdated
-npm outdated

## clean : clean up.
clean :
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,16 @@ before starting work on new features.
have to create one yourself.
The `--dev` flag installs development dependencies, required e.g. for testing.

1. Install [yarn][yarn], the tool that manages AMY's JavaScript and CSS dependencies. [You can install it here][yarn].
1. Install [node][nodejs] for front-end packages management.

1. Start running a local instance of Postgres and Redis. This requires Docker to be installed locally. Redis is required to have certain features (like creating a new person and viewing a workshop request) work correctly.
1. Install CSS, JS dependencies with (`npm` was installed in previous step when you
installed `node`):

~~~
$ npm install
~~~

1. Start running a local instance of Postgres and Redis. This requires Docker to be installed locally. Redis is required to have certain features (like creating a new person and viewing a workshop request) work correctly.

~~~
$ docker compose -f docker/docker-compose.yml -p amy up -d database redis
Expand Down Expand Up @@ -187,4 +194,4 @@ directory) with tags `amy:latest` and `amy:LAST_COMMIT`.
[tc]: https://carpentries.org/
[virtualenv]: https://virtualenv.pypa.io/en/latest/userguide.html
[venv]: https://docs.python.org/3/library/venv.html
[yarn]: https://yarnpkg.com/lang/en/docs/install
[nodejs]: https://nodejs.org/en/
51 changes: 45 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,73 @@
# $ GIT_COMMIT=$(git rev-parse --short HEAD)
# $ docker build -t amy:latest -t amy:$GIT_COMMIT --label commit=$GIT_COMMIT -f docker/Dockerfile .

# ----------------------------------
# BASE IMAGE: slim debian bullseye
# ----------------------------------
FROM python:3.11-slim-bullseye as base

# security updates
RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends libpq5


# ----------------------------------
# PYTHON DEPENDENCIES INSTALLATION
# ----------------------------------
FROM base AS dependencies

RUN mkdir /app
RUN apt-get install -y --no-install-recommends libpq-dev gcc libstdc++-10-dev
RUN python3 -m pip install pipenv
RUN mkdir /app
RUN mkdir /venv

# venv will exist in /app/.venv
ENV PIPENV_VENV_IN_PROJECT=true
# venv will exist under `/venv/amy`
ENV PIPENV_DONT_LOAD_ENV=true
ENV PIPENV_VENV_IN_PROJECT=false
ENV PIPENV_CUSTOM_VENV_NAME=amy
ENV WORKON_HOME=/venv
WORKDIR /app
COPY ./Pipfile* .
COPY . .

# install runtime dependencies
RUN pipenv sync


# ----------------------------------
# NODE DEPENDENCIES INSTALLATION
# ----------------------------------
FROM node:18-bullseye-slim AS node_dependencies
RUN mkdir /app

WORKDIR /app
COPY . .

# install front-end dependencies
RUN npm install


# ----------------------------------
FROM base AS release
# COPYING STATICFILES INTO FINAL DESTINATION
# ----------------------------------
FROM base AS staticfiles

COPY --from=dependencies /venv /venv
COPY --from=dependencies /app /app
COPY --from=node_dependencies /app/node_modules /app/node_modules

ENV DJANGO_SETTINGS_MODULE=config.settings
WORKDIR /app
RUN /venv/amy/bin/python manage.py collectstatic --no-input


# ----------------------------------
# RELEASE STAGE
# ----------------------------------
FROM base AS release

COPY --from=dependencies /venv /venv
COPY --from=staticfiles /app /app
COPY --from=node_dependencies /app/node_modules /app/node_modules

WORKDIR /app
EXPOSE 8000
CMD .venv/bin/gunicorn --workers=4 --bind=0.0.0.0:8000 --env DJANGO_SETTINGS_MODULE=config.settings config.wsgi
CMD /venv/amy/bin/gunicorn --workers=4 --bind=0.0.0.0:8000 --env DJANGO_SETTINGS_MODULE=config.settings config.wsgi
219 changes: 219 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading