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

build(docker): local deployment #1263

Closed
wants to merge 1 commit into from
Closed

Conversation

roschaefer
Copy link
Contributor

@roschaefer roschaefer commented Jun 25, 2024

Motivation

On the weekend we had a downtime on production because nginx configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it reproducible.

This PR is an attempt to create a docker container that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

Read about infrastructure as code: https://en.wikipedia.org/wiki/Infrastructure_as_code

How to test

  1. cd deployment
  2. docker build . --tag dreammall-deployment
  3. docker run -it -p 8080:80 dreammall-deployment sh .. and wait
  4. Following services are running:
  1. Be amazed

@roschaefer
Copy link
Contributor Author

docker ps --size shows:

c915d6813f70   dreammall-deployment   "./entrypoint.sh sh"   12 minutes ago   Up 12 minutes   0.0.0.0:8080->80/tcp, :::8080->80/tcp   charming_shamir   2.66GB (virtual 3.11GB)

This is obviously way too big. We can get it smaller by e.g. de-duplicating node dependencies.

RUN rc-update add pm2 boot
RUN rc-update add mariadb boot

RUN git clone --depth 1 https://github.com/dreammall-earth/dreammall.earth.git /var/www/localhost/htdocs/dreammall.earth
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a little silly. With a .dockerignore taking out node_modules we could COPY the content of the entire repository into the docker image.

@roschaefer roschaefer force-pushed the reproducable-deployment branch 2 times, most recently from 3acd282 to c461993 Compare June 25, 2024 16:44
@roschaefer roschaefer changed the title build(deployment): local deployment build(docker): local deployment Jun 25, 2024
@roschaefer roschaefer requested a review from Elweyn June 25, 2024 16:44
@roschaefer roschaefer marked this pull request as ready for review June 25, 2024 16:44
Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a docker container that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

Read about infrastructure as code: https://en.wikipedia.org/wiki/Infrastructure_as_code

How to test
-----------
1. `cd deployment`
2. `docker build . --tag dreammall-deployment`
3. `docker run -it -p 8080:80 dreammall-deployment sh` .. and wait
4. Following services are running:
  * http://localhost:8080/
  * http://localhost:8080/api
  * http://localhost:8080/docs
5. Be amazed
@roschaefer roschaefer force-pushed the reproducable-deployment branch from c461993 to 891a6e2 Compare June 25, 2024 16:50
@roschaefer
Copy link
Contributor Author

The only missing part here is the reverse proxy that forwards different stages, e.g. dreammall.earth or stage1.app.dreammall.earth to the container. I think this is fine to keep in mind. We can test things like nginx.conf files or pnpm in the docker container already.

@Elweyn Elweyn linked an issue Jun 27, 2024 that may be closed by this pull request
Copy link
Member

@Elweyn Elweyn left a comment

Choose a reason for hiding this comment

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

I had a problem with backend.
When I go on localhost:8080 and click on sign in I get on http://localhost:3000/signin instead of the frontend URL. (In presenter/.env it is defined to localhost:3000)

Except this it works. Goes in the right direction

Comment on lines +24 to +26
RUN cp backend/.env.dist backend/.env
RUN cp presenter/.env.dist presenter/.env
RUN cp frontend/.env.dist frontend/.env
Copy link
Member

Choose a reason for hiding this comment

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

Here we will need other values than the default ones

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually a paint point that becomes visible through this PR. What are the right values for production? Is it documented anywhere?

roschaefer added a commit that referenced this pull request Jun 27, 2024
Context
-------
There was a similar PR #1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine
2. `cd deployment/local-testing`
3. `vagrant up` .. and wait
4. Following services are running:
  * http://localhost:8080/
  * http://localhost:8080/api
  * http://localhost:8080/docs
5. Be amazed
roschaefer added a commit that referenced this pull request Jun 27, 2024
Context
-------
There was a similar PR #1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine
2. `cd deployment/local-testing`
3. `vagrant up` .. and wait
4. Following services are running:
  * http://localhost:8080/
  * http://localhost:8080/api
  * http://localhost:8080/docs
5. Be amazed
roschaefer added a commit that referenced this pull request Jun 27, 2024
Context
-------
There was a similar PR #1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine
2. `cd deployment/local-testing`
3. `vagrant up` .. and wait
4. Following services are running:
  * http://localhost:8080/
  * http://localhost:8080/api
  * http://localhost:8080/docs
5. Be amazed
@roschaefer
Copy link
Contributor Author

closed in favour of #1272

@roschaefer roschaefer closed this Jun 27, 2024
roschaefer added a commit to roschaefer/dreammall.earth that referenced this pull request Jun 27, 2024
Context
-------
There was a similar PR dreammall-earth#1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine
2. `cd deployment/local-testing`
3. `vagrant up` .. and wait
4. Following services are running:
  * http://localhost:8080/
  * http://localhost:8080/api
  * http://localhost:8080/docs
5. Be amazed
roschaefer added a commit to roschaefer/dreammall.earth that referenced this pull request Jun 27, 2024
Context
-------
There was a similar PR dreammall-earth#1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine
2. `cd deployment/local-testing`
3. `vagrant up` .. and wait
4. Following services are running:
  * http://localhost:8080/
  * http://localhost:8080/api
  * http://localhost:8080/docs
5. Be amazed
roschaefer added a commit that referenced this pull request Jun 27, 2024
Context
-------
There was a similar PR #1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine
2. `cd deployment/local-testing`
3. `vagrant up` .. and wait
4. Following services are running:
  * http://localhost:8080/
  * http://localhost:8080/api
  * http://localhost:8080/docs
5. Be amazed
roschaefer added a commit that referenced this pull request Jun 27, 2024
Context
-------
There was a similar PR #1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine
2. `cd deployment/local-testing`
3. `vagrant up` .. and wait
4. Following services are running:
  * http://localhost:8080/
  * http://localhost:8080/api
  * http://localhost:8080/docs
5. Be amazed
roschaefer added a commit that referenced this pull request Jun 30, 2024
Context
-------
There was a similar PR #1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine

1. `cd deployment/local-testing`

1. `vagrant up` .. and wait

1. Following services are running:
   - <http://localhost:8000/>
   - <http://localhost:8000/api>
   - <http://localhost:8000/docs>
   - <http://localhost:8080/>
   - <http://localhost:8082/>

1. Be amazed

In the future we might want to use [Ansible](https://www.ansible.com/) for provisioning. We could run our playbooks against this virtual machine, too.
roschaefer added a commit that referenced this pull request Jul 1, 2024
Context
-------
There was a similar PR #1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine

1. `cd deployment/local-testing`

1. `vagrant up` .. and wait

1. Following services are running:
   - <http://localhost:8000/>
   - <http://localhost:8000/api>
   - <http://localhost:8000/docs>
   - <http://localhost:8080/>
   - <http://localhost:8082/>

1. Be amazed

In the future we might want to use [Ansible](https://www.ansible.com/) for provisioning. We could run our playbooks against this virtual machine, too.
roschaefer added a commit that referenced this pull request Jul 1, 2024
Context
-------
There was a similar PR #1263 attempting to do the same with docker. I was running into isolation issues with docker (setting hostname not allowed in the container and some system folders are read-only) and learned that for this use case, an actual hypervisor would be better and vagrant is a conventional tool to set up these virtual machines.

Motivation
----------
On the weekend we had a downtime on production because `nginx` configurations got out of sync with the code in newer releases.

To prevent this and further downtimes I suggest to check in our deployment configuration and make it *reproducible*.

This PR is an attempt to create a virtual machine that behaves as similar as possible to production and can be used as a sandbox for changes to our deployment configuration.

How to test
-----------
1. Install [Vagrant](https://www.vagrantup.com/) on your machine

1. `cd deployment/local-testing`

1. `vagrant up` .. and wait

1. Following services are running:
   - <http://localhost:8000/>
   - <http://localhost:8000/api>
   - <http://localhost:8000/docs>
   - <http://localhost:8080/>
   - <http://localhost:8082/>

1. Be amazed

In the future we might want to use [Ansible](https://www.ansible.com/) for provisioning. We could run our playbooks against this virtual machine, too.
@mahula mahula deleted the reproducable-deployment branch July 25, 2024 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

💥 [DevOps] Deployment Process
2 participants