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

chore: reduce container size #259

Merged
merged 1 commit into from
Apr 9, 2024
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
8 changes: 2 additions & 6 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
FROM python:3.11.4
FROM python:3.11.4-alpine3.18

RUN apt update && apt install -y gettext libgettextpo-dev && pip install --upgrade pip && pip install -U poetry
RUN apk update && apk add --no-cache gettext libintl && pip install -U poetry
RUN poetry config virtualenvs.create false

WORKDIR /code

COPY pyproject.toml poetry.lock ./
RUN poetry install --only main

COPY . .

RUN ./setup.sh
6 changes: 3 additions & 3 deletions development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ services:
build:
context: $BACKEND_DIR
dockerfile: Dockerfile
command: /bin/bash -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080"
command: sh -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080"
expose:
- 8080
volumes:
Expand All @@ -60,7 +60,7 @@ services:
container_name: celery
build:
context: $BACKEND_DIR
dockerfile: Dockerfile.dev
dockerfile: Dockerfile
command: celery -A ypovoli worker -l DEBUG
volumes:
- ${BACKEND_DIR}:/code
Expand All @@ -74,7 +74,7 @@ services:
build:
context: $FRONTEND_DIR
dockerfile: Dockerfile.dev
command: bash -c "npm install && npm run host"
command: sh -c "npm install && npm run host"
expose:
- 5173
volumes:
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18
FROM node:18.17.1-alpine3.17

WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions frontend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18 as build-stage
FROM node:18.17.1-alpine3.17 as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
Expand All @@ -9,4 +9,4 @@ FROM nginx as production-stage
EXPOSE 3000
RUN mkdir /app
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build-stage /app/dist /app
COPY --from=build-stage /app/dist /app
4 changes: 2 additions & 2 deletions production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ services:
build:
context: $BACKEND_DIR
dockerfile: Dockerfile
command: bash -c "./setup.sh && gunicorn --config gunicorn_config.py ypovoli.wsgi:application"
command: sh -c "./setup.sh && gunicorn --config gunicorn_config.py ypovoli.wsgi:application"
expose:
- 8080
depends_on:
Expand All @@ -88,7 +88,7 @@ services:
container_name: celery
build:
context: $BACKEND_DIR
dockerfile: Dockerfile.prod
dockerfile: Dockerfile
command: celery -A ypovoli worker -l ERROR
volumes:
- ${BACKEND_DIR}:/code
Expand Down
12 changes: 5 additions & 7 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ else
vitest_exit=$?
fi

exit_code=0

echo "-----------------"
if [ $cypress_exit -ne 0 ] || [ $vitest_exit -ne 0 ] || [ $django_exit -ne 0 ]; then
echo "Tests failed:"
Expand All @@ -97,20 +99,16 @@ if [ $cypress_exit -ne 0 ] || [ $vitest_exit -ne 0 ] || [ $django_exit -ne 0 ];
if [ $django_exit -ne 0 ]; then
echo " - Django"
fi
echo "-----------------"
echo "Cleaning up..."
docker-compose -f test.yml down
echo "Done."
exit 1
exit_code=1
else
echo "All tests passed!"
fi
echo "-----------------"

echo "Cleaning up..."

docker-compose -f test.yml down
docker-compose -f test.yml down --rmi all

echo "Done."

exit 0
exit $exit_code
25 changes: 11 additions & 14 deletions test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ networks:

############################# EXTENSIONS

x-common-keys-selab: &common-keys-selab
x-common-keys-selab_test: &common-keys-selab_test
networks:
- test_selab_network
security_opt:
- no-new-privileges:true
restart: unless-stopped
restart: "no"
environment:
TZ: $TZ
PUID: $PUID
Expand All @@ -29,7 +29,7 @@ x-common-keys-selab: &common-keys-selab

services:
test_nginx:
<<: *common-keys-selab
<<: *common-keys-selab_test
image: nginx:latest
container_name: test_nginx
expose:
Expand All @@ -44,37 +44,37 @@ services:
- test_frontend

test_backend:
<<: *common-keys-selab
<<: *common-keys-selab_test
container_name: test_backend
build:
context: $BACKEND_DIR
dockerfile: Dockerfile
command: /bin/bash -c "./setup.sh && python manage.py runsslserver 192.168.91.2:8080"
command: sh -c "./setup.sh && python manage.py runsslserver 192.168.91.2:8080"
expose:
- 8080
volumes:
- $BACKEND_DIR:/code

test_celery:
<<: *common-keys-selab
<<: *common-keys-selab_test
container_name: test_celery
build:
context: $BACKEND_DIR
dockerfile: Dockerfile
command: celery -A ypovoli worker -l DEBUG
command: sh -c "poetry install && celery -A ypovoli worker -l DEBUG"
volumes:
- $BACKEND_DIR:/code
depends_on:
- test_backend
- test_redis

test_frontend:
<<: *common-keys-selab
<<: *common-keys-selab_test
container_name: test_frontend
build:
context: $FRONTEND_DIR
dockerfile: Dockerfile.dev
command: bash -c "npm install && npm run host"
command: sh -c "npm install && npm run host"
expose:
- 5173
volumes:
Expand All @@ -83,7 +83,7 @@ services:
- test_backend

test_redis:
<<: *common-keys-selab
<<: *common-keys-selab_test
container_name: test_redis
image: redis:latest
networks:
Expand All @@ -96,12 +96,9 @@ services:
- ${DATA_DIR}/redis:/data

test_cypress:
<<: *common-keys-selab
<<: *common-keys-selab_test
container_name: test_cypress
image: cypress/included:cypress-12.17.3-node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1
restart: "no"
working_dir: /e2e
volumes:
- ${FRONTEND_DIR}:/e2e
extra_hosts:
- "host.docker.internal:host-gateway"
Loading