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

59 deploy refactor coaching platform #73

Merged
merged 6 commits into from
Nov 26, 2024

Conversation

lmcdonough
Copy link
Contributor

@lmcdonough lmcdonough commented Oct 18, 2024

This pull request includes significant changes to set up a Rust web application with PostgreSQL using Docker and Docker Compose. It also provides detailed documentation for deployment and usage. The most important changes include the creation of a Dockerfile for building and running the Rust application, a docker-compose.yaml file for orchestrating services, and comprehensive documentation for setup and deployment.

Docker and Docker Compose Setup:

  • Dockerfile: Created a multi-stage Dockerfile to build the Rust application and set up the environment for running it with PostgreSQL. This includes installing necessary dependencies, copying the source code, and defining environment variables and health checks.
  • docker-compose.yaml: Added a Docker Compose configuration to define services for the Rust application and PostgreSQL. This includes environment variables, ports, and network configurations.

Documentation:

  • docs/runbooks/Container-README.md: Added a comprehensive README for setting up and running the Rust web application with PostgreSQL using Docker and Docker Compose. This includes prerequisites, project setup, building and running the application, using database utilities, and troubleshooting.
  • docs/runbooks/deploy.md: Added a detailed deployment runbook for deploying the Rust application on an Ubuntu server using Ansible and Terraform. This covers both containerized and native deployment methods, including initial server setup, application deployment, and Terraform configuration.## Description
    describe the intent of your changes here

GitHub Issue: Resolves #59

Changes

  • ...
  • ...
  • ...

Testing Strategy

describe how you or someone else can test and verify the changes

Concerns

describe any concerns that might be worth mentioning or discussing

@lmcdonough lmcdonough linked an issue Oct 18, 2024 that may be closed by this pull request
2 tasks
@jhodapp jhodapp added enhancement Improves existing functionality or feature feature work Specifically implementing a new feature labels Oct 18, 2024
@lmcdonough lmcdonough force-pushed the 59-deploy-refactor-coaching-platform branch from 477362a to 39db1b6 Compare October 18, 2024 22:30
@lmcdonough lmcdonough marked this pull request as ready for review October 18, 2024 22:37
Copy link
Member

@jhodapp jhodapp left a comment

Choose a reason for hiding this comment

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

Looking very good Levi, thank you for this. Some initial feedback/questions.

Dockerfile Outdated Show resolved Hide resolved
docker-compose.yaml Show resolved Hide resolved
docs/runbooks/Container-README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@calebbourg calebbourg left a comment

Choose a reason for hiding this comment

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

This looks really good. Thank you, especially, for all of the fantastic documentation. That's super helpful. I just left a few questions.

Cargo.toml Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated
Comment on lines 33 to 51
RUN apt-get update && apt-get install -y \
libssl1.1 \
ca-certificates \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm always curious how one determines exactly what is needed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this part to make sure the container has all the system dependencies needed for the Rust app to run correctly, specifically libraries and certificates. libssl1.1 for SSL support, ca-certificates for verifying HTTPS connections, and libpq5 for PostgreSQL connections. Clearing /var/lib/apt/lists just reduces image size by removing cached package data. Hope that helps.

@lmcdonough lmcdonough force-pushed the 59-deploy-refactor-coaching-platform branch from 4a4140e to fd99832 Compare November 8, 2024 22:38
Dockerfile Outdated Show resolved Hide resolved
@jhodapp
Copy link
Member

jhodapp commented Nov 18, 2024

FYI: Built the working image using this .env file:

# PostgreSQL environment variables for local development
POSTGRES_USER=refactor  # Default PostgreSQL user for local development
POSTGRES_PASSWORD=password  # Default PostgreSQL password for local development
POSTGRES_DB=refactor  # Default PostgreSQL database for local development
POSTGRES_HOST=postgres  # The local Docker Compose PostgreSQL container hostname
POSTGRES_PORT=5432  # PostgreSQL default port for local development
POSTGRES_SCHEMA=refactor_platform  # PostgreSQL schema for the application
# Database connection URL for the Rust application
DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
# Rust application environment variables
SERVICE_INTERFACE=0.0.0.0
SERVICE_PORT=4000

# App user configuration
USERNAME=appuser  # Username for the non-root user in the container
USER_UID=1000  # User ID for the appuser
USER_GID=1000  # Group ID for the appuser

@lmcdonough lmcdonough requested a review from jhodapp November 20, 2024 00:47
Dockerfile Show resolved Hide resolved
Copy link
Member

@jhodapp jhodapp left a comment

Choose a reason for hiding this comment

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

This still builds and functions well for me with your latest commit. I think it's great for our first version. Thanks for working together to get this across the finish line with me.

@lmcdonough lmcdonough force-pushed the 59-deploy-refactor-coaching-platform branch from a708624 to 276c150 Compare November 24, 2024 17:33
@lmcdonough lmcdonough requested a review from jhodapp November 24, 2024 18:23
Copy link
Member

@jhodapp jhodapp left a comment

Choose a reason for hiding this comment

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

Looking great @lmcdonough, thank you for this. A few suggested changes inline. Could you also add a short section to the main README.md file that points a reader to the container README for how to build/start the containerized application?

docs/runbooks/Container-README.md Outdated Show resolved Hide resolved
docs/runbooks/Container-README.md Outdated Show resolved Hide resolved
### **Convert DBML to SQL**

If you have a DBML file (`schema.dbml`), you can convert it into an SQL schema:

If you have a DBML file (`schema.dbml`), convert it to SQL:
Copy link
Member

Choose a reason for hiding this comment

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

This part isn't really needed since a developer is responsible for converting the DBML diagram to a .sql file as part of their commit if they change the DB's table structures.

Copy link
Member

@jhodapp jhodapp left a comment

Choose a reason for hiding this comment

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

LGTM

@lmcdonough lmcdonough merged commit d69a2e2 into main Nov 26, 2024
4 checks passed
@lmcdonough lmcdonough deleted the 59-deploy-refactor-coaching-platform branch November 26, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves existing functionality or feature feature work Specifically implementing a new feature
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Deploy Refactor coaching platform
3 participants