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

Use Alpine as root image #795

Merged
merged 3 commits into from
Jun 10, 2020
Merged

Use Alpine as root image #795

merged 3 commits into from
Jun 10, 2020

Conversation

harmw
Copy link
Contributor

@harmw harmw commented May 26, 2020

This supports #794 , though right now it only works for the main backend/frontend containers. I haven't looked at the supporting stuff, like something mssql I noticed :)

@kuraga kuraga mentioned this pull request May 27, 2020
@Hironsan
Copy link
Member

Hironsan commented Jun 9, 2020

Thank you @harmw . I was suprised that the images are small(backend: 1.22GB -> 215MB, frontend: 1.25GB -> 479MB)

By the way, I executed the following docker-compose command. The build was successful but the running was failed:

> docker-compose -f docker-compose.prod.yml up
...
Successfully built 2f567b196783
Successfully tagged doccano_nginx:latest
WARNING: Image for service nginx was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating doccano_frontend_1 ... done
Creating doccano_postgres_1 ... done
Creating doccano_backend_1  ... done
Creating doccano_nginx_1    ... done
Attaching to doccano_postgres_1, doccano_frontend_1, doccano_backend_1, doccano_nginx_1
backend_1   | env: can't execute 'bash': No such file or directory
postgres_1  | 2020-06-09 06:25:30.206 UTC [1] LOG:  starting PostgreSQL 12.0 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.3.0) 8.3.0, 64-bit
postgres_1  | 2020-06-09 06:25:30.207 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_1  | 2020-06-09 06:25:30.207 UTC [1] LOG:  listening on IPv6 address "::", port 5432
nginx_1     | 2020/06/09 06:25:31 [emerg] 1#1: host not found in upstream "backend" in /etc/nginx/conf.d/nginx.conf:15
nginx_1     | nginx: [emerg] host not found in upstream "backend" in /etc/nginx/conf.d/nginx.conf:15
postgres_1  | 2020-06-09 06:25:30.210 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1  | 2020-06-09 06:25:30.225 UTC [18] LOG:  database system was shut down at 2020-06-09 05:59:59 UTC
postgres_1  | 2020-06-09 06:25:30.229 UTC [1] LOG:  database system is ready to accept connections
doccano_frontend_1 exited with code 0
doccano_backend_1 exited with code 127
doccano_nginx_1 exited with code 1

There may be a problem in backend. As a result, nginx container exited with code 1.

My environment:

  • docker-compose version 1.25.5, build 8a1c60f6
  • Docker version 19.03.8, build afacb8b

@harmw
Copy link
Contributor Author

harmw commented Jun 9, 2020

backend_1   | env: can't execute 'bash': No such file or directory

hm, did I miss that somewhere? Things on my end just worked, given not using docker-compose. Let me take a look, I did notice an unrelated issue with the frontend failing to start when using the prod compose, but didn't bother looking into that as I had that problem also in master.

@Hironsan
Copy link
Member

When I changed Dockerfile and run.sh, it works fine.

Dockerfile(install bash)

RUN apk add -U python3 python3-dev libpq postgresql-dev unixodbc-dev musl-dev g++ libffi-dev bash\

run.sh

  • python -> python3

But I don't want to change run.sh as much as possible.

@harmw
Copy link
Contributor Author

harmw commented Jun 10, 2020

$ docker-compose -f docker-compose.prod.yml up
Creating network "doccano_default" with the default driver
Creating network "doccano_network-backend" with the default driver
Creating network "doccano_network-frontend" with the default driver
Creating doccano_postgres_1 ... done
Creating doccano_frontend_1 ... done
Creating doccano_backend_1  ... done
Creating doccano_nginx_1    ... done
Attaching to doccano_postgres_1, doccano_frontend_1, doccano_backend_1, doccano_nginx_1
backend_1   | Making staticfiles
postgres_1  | 2020-06-10 10:37:45.504 UTC [1] LOG:  starting PostgreSQL 12.0 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.3.0) 8.3.0, 64-bit
postgres_1  | 2020-06-10 10:37:45.505 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_1  | 2020-06-10 10:37:45.506 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres_1  | 2020-06-10 10:37:45.511 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1  | 2020-06-10 10:37:45.542 UTC [18] LOG:  database system was interrupted; last known up at 2020-05-23 14:10:53 UTC
postgres_1  | 2020-06-10 10:37:45.682 UTC [18] LOG:  database system was not properly shut down; automatic recovery in progress
postgres_1  | 2020-06-10 10:37:45.685 UTC [18] LOG:  redo starts at 0/178E738
postgres_1  | 2020-06-10 10:37:45.685 UTC [18] LOG:  invalid record length at 0/178E770: wanted 24, got 0
postgres_1  | 2020-06-10 10:37:45.685 UTC [18] LOG:  redo done at 0/178E738
postgres_1  | 2020-06-10 10:37:45.695 UTC [1] LOG:  database system is ready to accept connections
doccano_frontend_1 exited with code 0
backend_1   |
backend_1   | 0 static files copied to '/app/staticfiles', 315 unmodified, 1009 post-processed.
backend_1   | Initializing database
backend_1   | Operations to perform:
backend_1   |   Apply all migrations: admin, api, auth, authtoken, contenttypes, sessions, social_django
backend_1   | Running migrations:
backend_1   |   No migrations to apply.
backend_1   |   Your models have changes that are not yet reflected in a migration, and so won't be applied.
backend_1   |   Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
backend_1   | CommandError: Error: That username is already taken.
backend_1   | Starting django
backend_1   | [2020-06-10 10:38:27 +0000] [26] [INFO] Starting gunicorn 19.9.0
backend_1   | [2020-06-10 10:38:27 +0000] [26] [INFO] Listening at: http://0.0.0.0:8000 (26)
backend_1   | [2020-06-10 10:38:27 +0000] [26] [INFO] Using worker: sync
backend_1   | [2020-06-10 10:38:27 +0000] [29] [INFO] Booting worker with pid: 29

That's not what you got, let me check if maybe I got some outdated containers dangling around 🤔

Let me try again and start with a wipe of my docker-box.

--edit--

Successfully built 1a37b4f1f1f5
Successfully tagged doccano_nginx:latest
WARNING: Image for service nginx was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating doccano_frontend_1 ... done
Creating doccano_postgres_1 ... done
Creating doccano_backend_1  ... done
Creating doccano_nginx_1    ... done
Attaching to doccano_postgres_1, doccano_frontend_1, doccano_backend_1, doccano_nginx_1
backend_1   | env: can't execute 'bash': No such file or directory
postgres_1  | 2020-06-10 10:57:47.338 UTC [1] LOG:  starting PostgreSQL 12.0 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.3.0) 8.3.0, 64-bit
postgres_1  | 2020-06-10 10:57:47.338 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_1  | 2020-06-10 10:57:47.338 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres_1  | 2020-06-10 10:57:47.341 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1  | 2020-06-10 10:57:47.388 UTC [18] LOG:  database system was shut down at 2020-06-10 10:38:58 UTC
postgres_1  | 2020-06-10 10:57:47.403 UTC [1] LOG:  database system is ready to accept connections
doccano_backend_1 exited with code 127
doccano_frontend_1 exited with code 0
nginx_1     | 2020/06/10 10:57:48 [emerg] 1#1: host not found in upstream "backend" in /etc/nginx/conf.d/nginx.conf:15
nginx_1     | nginx: [emerg] host not found in upstream "backend" in /etc/nginx/conf.d/nginx.conf:15
doccano_nginx_1 exited with code 1

BAM, now let me fix that :)

Pip3 doesn't need to be symlinked as the creation of /usr/bin/pip is
done through installation of setuptools (or the pip upgrade).
@harmw
Copy link
Contributor Author

harmw commented Jun 10, 2020

should be fine now 👍

@Hironsan Hironsan merged commit 792f4ec into doccano:master Jun 10, 2020
@Hironsan
Copy link
Member

Thanks! It works fine.

@kuraga
Copy link
Contributor

kuraga commented Jun 10, 2020

🎉

@harmw , can we clean cache?

@kuraga kuraga mentioned this pull request Jun 10, 2020
@harmw
Copy link
Contributor Author

harmw commented Jun 10, 2020

@kuraga it doesn't seem to be caching 🙈

/ # apk cache -v sync
ERROR: Package cache is not enabled.

As this branch got merged, if it's okay with you, let's create a separate issue about better cache cleaning (if any) - should that be required 👍

@harmw harmw deleted the alpine branch June 10, 2020 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants