Learn how to deploy with docker using Docker Compose to run containers sharing the same virtual network but isolated from other instances on the same host…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Microservices, Part 2
Mar 30 2021 · Chapter
…this chapter, you’ll learn about API gateways and how to make microservices accessible to clients. Finally, you’ll learn how to use Docker and Docker Compose to spin up the whole application. The API gateway The previous chapter introduced two microservices for the TIL application, one for acronyms…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Configuring a Database
Mar 30 2021 · Chapter
…learn how to configure your Vapor application to integrate with the database of your choice. This chapter, and most of the book, uses Docker to host the database. Docker is a containerization technology that allows you to run independent images on your machine without the overhead of virtual machines…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Testing
Mar 30 2021 · Chapter
…application from the previous chapters. Finally, you’ll see why testing matters on Linux and how to test your code on Linux using Docker…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Advanced Fluent
Mar 30 2021 · Chapter
…need to delete the existing database. This chapter contains model changes which require either reverting your database or deleting it. In Terminal, type: docker rm -f postgres This stops the Docker container named postgres if it’s running and deletes it. Creating a new database Create a new database…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Production Concerns & Redis
Mar 30 2021 · Chapter
…differences in implementation can cause bugs in your code. Sometimes, an API’s implementation may not yet exist for a platform. Container environments like Docker help you address this by making it easy to test your code on platforms different from your host machine, such as testing on Linux while…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Microservices, Part 1
Mar 30 2021 · Chapter
MySQL database to store the acronyms. The user microservice Navigate to the TILAppUsers directory in Terminal. Enter the following the start the database: docker run --name postgres -e POSTGRES_DB=vapor_database \ -e POSTGRES_USER=vapor_username \ -e POSTGRES_PASSWORD=vapor_password \ -p 5432:5432 -d postgres Here’s what…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Parent-Child Relationships
Mar 30 2021 · Chapter
…chapter requires that you have set up and configured PostgreSQL. Follow the steps in Chapter 6, “Configuring a Database”, to set up PostgreSQL in Docker and configure the Vapor application. Parent-child relationships Parent-child relationships describe a relationship where one model has “ownership” of one or more models. They…
Multiple Domains
Chapter in Server-Side Swift with Vapor
API Authentication, Part 1
Mar 30 2021 · Chapter
…column to the table, you must delete the database so Fluent will run the migration again. In Terminal, enter: # 1 docker stop postgres # 2 docker rm postgres # 3 docker run --name postgres -e POSTGRES_DB=vapor_database \ -e POSTGRES_USER=vapor_username \ -e POSTGRES_PASSWORD=vapor_password…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Fluent & Persisting Models
Mar 30 2021 · Chapter
…including how to create routes. This chapter explains how to use Fluent to save data in Vapor applications. You’ll need to have Docker installed and running. Visit https://www.docker.com/get-docker and follow the instructions to install it. Fluent Fluent is Vapor’s ORM or object relational mapping tool…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Adding Profile Pictures
Mar 30 2021 · Chapter
…optional. Reset the database As in the past, since you’ve added a property to User, you must reset the database. In Terminal, run: docker rm -f postgres docker rm -f postgres-test docker run --name postgres -e POSTGRES_DB=vapor_database \ -e POSTGRES_USER=vapor_username \ -e POSTGRES_PASSWORD…
Multiple Domains
Server-Side Swift with Vapor
Mar 30 2021 · Book
…introduces the basics of Vapor; it then walks you through creating APIs and web backends; creating and configuring databases; deploying to Heroku, AWS, or Docker; testing your creations and more…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Password Reset & Emails
Mar 30 2021 · Chapter
…custom working directory in Xcode. Then, run the tests and they should all pass. Note: You must have the test database in Docker running for the tests to work. See Chapter 11, “Testing”, for details on how to set this up. Running the app The application should now compile. Before…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Sign in with Apple Authentication
Mar 30 2021 · Chapter
…file: IOS_APPLICATION_IDENTIFIER=<YOUR_BUNDLE_ID> Then, in Terminal, reset the database to accommodate the new field on User: docker rm -f postgres docker run --name postgres \ -e POSTGRES_DB=vapor_database \ -e POSTGRES_USER=vapor_username \ -e POSTGRES_PASSWORD=vapor_password \ -p 5432:5432 -d postgres…
Multiple Domains
Chapter in Server-Side Swift with Vapor
API Authentication, Part 2
Mar 30 2021 · Chapter
This ensures the username is unique as required by the migration. Hash the password and create a user. In Terminal, run the following: # 1 docker rm -f postgres-test # 2 docker run --name postgres-test -e POSTGRES_DB=vapor-test \ -e POSTGRES_USER=vapor_username \ -e POSTGRES_PASSWORD=vapor_password…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Database/API Versioning & Migration
Mar 30 2021 · Chapter
…property in your table. On your development machine, you can see the table’s properties by entering the following in Terminal: docker exec -it postgres psql -U vapor_username vapor_database \d "users" \q Versioning the API You’ve changed the model to include the user’s Twitter handle…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Deploying with AWS
Mar 30 2021 · Chapter
…load balancers and custom DNS names with TLS certificates. There are also other deployment options, such as running in Docker or even using AWS Lambda. Covering all of AWS would be a whole book in itself! Spend some time with the AWS documentation and tutorials to learn more. When…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Creating a Simple iPhone App, Part 1
Mar 30 2021 · Chapter
…application that the iOS app will talk to. You can use your existing TIL app if you like. Note: This requires that your Docker container for the database is running. See Chapter 6, “Configuring a Database”, for instructions. Next, open the TILiOS project. TILiOS contains a skeleton application that interacts…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Sibling Relationships
Mar 30 2021 · Chapter
…chapter requires that you have set up and configured PostgreSQL. Follow the steps in Chapter 6, “Configuring a Database”, to set up PostgreSQL in Docker and configure the Vapor application. Sibling relationships Sibling relationships describe a relationship that links two models to each other. They are also known as many…
Multiple Domains
Chapter in Server-Side Swift with Vapor
Controllers
Mar 30 2021 · Chapter
…chapter requires that you have set up and configured PostgreSQL. Follow the steps in Chapter 6, “Configuring a Database”, to set up PostgreSQL in Docker and configure the Vapor application. Controllers Controllers in Vapor serve a similar purpose to controllers in iOS. They handle interactions from a client, such…