# Build Pixelfed using Docker on Windows

日本語版: 日本語で読む

Table of Contents

What is Pixelfed?

Instagram is open source and uses a decentralized architecture similar to Mastodon.

In other words, it is part of the Fediverse.

“A more attractive (and ethical) alternative” to Instagram

It may or may not have been said.

I had a lot of trouble before building, so I’ll write down how to do it.

Not only was it quite difficult, but it was so difficult that I thought I was going to give up. Since the main premise is the front end, there is probably a lack of knowledge about Docker.

If you’re used to Docker, something like this might be a piece of cake.

Click here for the document

Pixelfed Docs

Creating an Env

The first thing that confused me was that there were a lot of Env.

  • .env.docker
  • .env.example
  • .env.testing

I didn’t know which one to use.

After doing some research, I found out that env.docker is used.

At this point, it’s a little different from what’s written in the Docs, so I’m not sure if this is correct.

By default Pixelfed comes with a .env.example file for production deployments, and a .env.testing file for debug deployments. You’ll need to rename or copy one of these files to .env regardless of which environment you’re working on.

However, the method that worked was to use env.docker, so I will proceed with this method.

Terminal window
cp env.docker .env

Copy env.docker to .env with the above command.

Next, change the following values ​​to your desired values.

Terminal window
APP_NAME="PixelfedExample"
APP_DOMAIN="pixelfed.example.com"
ENFORCE_EMAIL_VERIFICATION="false"
INSTANCE_CONTACT_EMAIL="メールアドレス"
DB_PASSWORD="パスワード"

By the way, I tried changing APP_DOMAIN to localhost, but there seems to be a validation and I could only set it to a domain name in a specific format.

By setting APP_DOMAIN, you can open the service with pixelfed.example.com.

Perhaps that setting is described in docker\nginx\root\docker\templates\etc\nginx\conf.d\default.conf.

Terminal window
server {
listen 80 default_server;
server_name {{ getenv "APP_DOMAIN" }};

If this is all you do, the link between your specified domain and IP address will not be completed, so you will need to modify the hosts file and link it.

C:\Windows\System32\drivers\etc\hosts

and at the end

127.0.0.1 pixelfed.example.com

Add this.

Launch Docker

docker compose up -d

Start Docker with the command.

When things don’t go well,

docker compose logs --follow

Check the log and make corrections.

This time, I want the authentication key to be written in the log, so

docker compose exec web php artisan passport:keys

Create Key with.

And we will work patiently with Docker until the problem disappears.

Create an account

Once all issues with Docker are resolved, create an account.

Terminal window
docker compose exec -u www-data web php artisan user:create
Creating a new user...
Name:
> name_id
Username:
> username
Email:
> email
Password:
>
Confirm Password:
>
Make this user an admin? (yes/no) [no]:
> yes
Manually verify email address? (yes/no) [no]:
> yes
Are you sure you want to create this user? (yes/no) [no]:
> yes
Created new user!

Now that the settings are complete, when you access pixelfed.example.com, the top page will be displayed.

Create a certificate (nginx.crt) and private key (nginx.key)

Finally, create a certificate so that you can connect with https.

mkdir -p docker/nginx/ssl && openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout docker/nginx/ssl/nginx.key -out docker/nginx/ssl/nginx.crt -subj "//C=JP/ST=Tokyo/L=Tokyo/O=Dev/CN=pixelfed.example.com"

The following two files will be created.

pixelfed\docker\nginx\ssl\nginx.crt
pixelfed\docker\nginx\ssl\nginx.key

You can now successfully connect Https.

Hot reload doesn’t work

I tried to customize it with great enthusiasm, but even when I touched the source, the screen did not update.

If anything,

docker compose down
docker compose up -d

But it’s not updated.

docker compose up --build -d

I was able to confirm that it was updated.

Since this is a new problem, I will investigate to resolve it (mounting issue?), but since I was able to build it, I’ll accept it as OK.

postscript

docker compose up --build -d

blade is updated.

npm run development
docker compose up --build -d

vue is applied.

…Maybe this is the correct way to operate it.


More Posts
My avatar

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.


Comments