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

Replace base image to alpine #240

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

NingZhou-NZ
Copy link

@NingZhou-NZ NingZhou-NZ commented May 21, 2023

I replced the base image of apache, nginx, postgresql, nodejs, redis and memcache to alpine linux.
The reason for replacement were that alpine linux is smaller and consume less resource and less vulnerability.
I will replace those php image in next commit.

@NingZhou-NZ NingZhou-NZ changed the title replace base image to alpine Replace base image to alpine May 21, 2023
@derschatta
Copy link
Member

derschatta commented May 22, 2023

Haven't had a chance to look at the full amount of changes but there's definitely too many different things put into one PR/commit. Can the changes to alpine be separated from the introduction of new containers? Any change not related should be in it's own PR. Ideally each new feature should have its own commit and the pr clearly needs to reflect that

@NingZhou-NZ
Copy link
Author

@codyfinegan @derschatta I seperated my original commit to four different commits

@NingZhou-NZ
Copy link
Author

I also added method for creating image according to the cpu architecture

@NingZhou-NZ
Copy link
Author

Let me know if you want me to make PR for each commits.

@derschatta derschatta added the enhancement New feature or request label Aug 31, 2023
Copy link
Member

@derschatta derschatta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NingZhou-NZ I think we should get some of the changes in here in. Although this now requires a rebase and some changes (see my comments).

@@ -1,7 +1,6 @@
log_errors = On
error_log = /dev/stderr
error_reporting = E_ALL & ~E_DEPRECATED
max_input_vars = 2000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this change necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in the PHP Dockerfiles are obsolete, they have been updated to bullseye in #248.

Moving the PHP containers to alpine is possible I think but requires a bit more work. I have experimented with it locally and can add a followup patch at a later stage.

@@ -1,8 +1,9 @@
FROM nginx:1.20
ARG ARCH=amd64
FROM $ARCH/nginx:alpine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ARCH (we don't want to optimise for only one architecture, rather build an image which supports both, arm and amd).

And change image to nginx:1.25-alpine

@@ -2,7 +2,7 @@ version: "3.7"
services:

pgsql93:
image: postgres:9.3
image: postgres:9.3-alpine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the pgsql images have been changed to alpine in #250

container_name: totara_pgsql10
ports:
- "5410:5432"
environment:
TZ: ${TIME_ZONE}
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_HOST_AUTH_METHOD: trust
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens without this environment variable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I try to remove the db password from local image.

# Check the OS and make image for that OS
if [ $(uname -m) == "arm64" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't it automatically use the one you are currently running?

@@ -1,6 +1,7 @@
FROM httpd:2.4
ARG ARCH=amd64
FROM $ARCH/httpd:2.4-alpine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the ARCH, we don't want to build only for one architecture.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also docker will automatically pick the right arch depending on the host I believe.

@@ -8,7 +8,7 @@ services:
# docker-compose -f docker-compose.yml -f compose/nginx.yml -f compose/pgsql.yml -f compose/php.yml up -d pgsql php-7.3

nodejs:
image: node:16
image: node:16-alpine3.16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe should be node:16-alpine?

@@ -28,7 +28,8 @@ services:
- totara

redis:
image: redis
image: redis:alpine
container_name: totara_redis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could create problems if someone has been running it before, conflicts with existing containers. Not strictly necessay anyway, so maybe it's safer to not add container names in this patch.

@derschatta
Copy link
Member

actually I just found out that alpine has difference uid/guid for www-data. In the entrypoint.sh for nginx we are setting the ownership of the data root folder to www-data. This is problematic if not all images accessing it use alpine. I think we should hold off mixing alpine and non-alpine for now. It only works if all images are based on alpine I think. Maybe except the database containers as they are pretty self-contained.

@derschatta derschatta marked this pull request as draft September 5, 2023 03:16
@derschatta
Copy link
Member

was able to convert two of the PHP images to use the alpine base images, see #252 as a draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants