Open marinasundstrom opened 3 years ago
This is what I came up with:
tye.yaml
:
# tye application configuration file
# read all about it at https://github.com/dotnet/tye
#
# when you've given us a try, we'd love to know what you think:
# https://aka.ms/AA7q20u
#
name: peachpie-wordpress
services:
- name: app
project: app/app.csproj
- name: wordpress-mysql
image: mysql/mysql-server:latest
bindings:
- port: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "P@ssw0rd"
- name: MYSQL_DATABASE
value: "wordpress"
- name: MYSQL_USER
value: "user"
- name: MYSQL_PASSWORD
value: "P@ssw0rd"
In Program.cs
, remove or comment out .UseUrls("http://*:5004/")
. Since bindings will be handled by Tye.
static void Main(string[] args)
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(Program).Assembly.Location));
//
var host = WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
//.UseUrls("http://*:5004/")
.Build();
host.Run();
}
Update connection details in ``appsettings.Development.json```:
{
"WordPress": {
"dbhost": "localhost",
"dbpassword": "P@ssw0rd",
"dbuser": "user",
"dbname": "wordpress",
}
}
Now you have the Wordpress db in MySQL running in Docker.
Am I missing something?
I have not figured out persistence and mapping volumes yet.
Update: Mount /var/lib/mysql
to the ./data/mysql
.
- name: wordpress-mysql
image: mysql/mysql-server:latest
bindings:
- port: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "P@ssw0rd"
- name: MYSQL_DATABASE
value: "wordpress"
- name: MYSQL_USER
value: "user"
- name: MYSQL_PASSWORD
value: "P@ssw0rd"
volumes:
- source: .data/mysql
target: /var/lib/mysql
And to bind the Wordpress app to specific port:
name: peachpie-wordpress
services:
- name: app
project: app/app.csproj
bindings:
- port: 5004
protocol: http
The ports assigned will normally be random.
I'm working on a sample for a headless app using Blazor as a frontend. Tye is used for orchestrating during dev.
Here is my headless Wordpress with a Blazor frontend: https://github.com/robertsundstrom/headless-wordpress-blazor
Description Add a tye configuration file that configures the app project and MySQL (in Docker).
Reason It makes it easier to start developing without having to install MySQL locally.
What needs to be done
tye.yaml
fileMicrosoft.Tye.Extensions.Configuration
packageQuestion Is it difficult to do this?