Skip to content

Commit

Permalink
Rewrite devcontainer similar to friendica docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ne20002 committed Feb 8, 2025
1 parent 5e00120 commit e231007
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ MYSQL_HOST=127.0.0.1
MYSQL_DATABASE=friendica
MYSQL_USER=friendica
MYSQL_PASSWORD=friendica
MYSQL_ROOT_PASSWORD=root


#Friendica setup
FRIENDICA_ADMIN_MAIL=root@friendica.local

#Redis
REDIS_HOST=127.0.0.1
Expand Down
100 changes: 81 additions & 19 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,70 @@ ARG VARIANT="8.2-apache-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/php:${VARIANT}

ARG DEBIAN_FRONTEND=noninteractive
ARG apcu_version=5.1.23
ARG memcached_version=3.2.0
ARG redis_version=6.0.2
ARG apcu_version=5.1.24
ARG memcached_version=3.3.0
ARG redis_version=6.1.0
ARG imagick_version=3.7.0

RUN apt-get update -y;

# Install MariaDB client
RUN apt-get install -y mariadb-client

# Base packages
RUN apt install -y vim software-properties-common sudo nano gnupg2

# entrypoint.sh and cron.sh dependencies
RUN apt-get install -y --no-install-recommends \
rsync \
bzip2 \
msmtp \
tini
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends \
rsync \
bzip2 \
msmtp \
tini \
;

ENV GOSU_VERSION 1.17
RUN set -eux; \
# save list of currently installed packages for later so we can clean up
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates wget; \
if ! command -v gpg; then \
apt-get install -y --no-install-recommends gnupg2 dirmngr; \
elif gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \
# "This package provides support for HKPS keyservers." (GnuPG 1.x only)
apt-get install -y --no-install-recommends gnupg-curl; \
fi; \
rm -rf /var/lib/apt/lists/*; \
\
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
\
# verify the signature
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
command -v gpgconf && gpgconf --kill all || :; \
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
\
# clean up fetch dependencies
apt-mark auto '.*' > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
\
chmod +x /usr/local/bin/gosu; \
# verify that the binary works
gosu --version; \
gosu nobody true

RUN apt-get install -y --no-install-recommends \
# install the PHP extensions we need
# see https://friendi.ca/resources/requirements/
RUN set -ex; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
mariadb-client \
bash \
libpng-dev \
libjpeg62-turbo-dev \
Expand All @@ -41,12 +84,12 @@ RUN apt-get install -y --no-install-recommends \
libmagickcore-6.q16-6-extra \
; \
\
docker-php-ext-configure gd \
docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp \
; \
docker-php-ext-install -j "$(nproc)" \
docker-php-ext-install -j "$(nproc)" \
pdo_mysql \
gd \
exif \
Expand All @@ -56,18 +99,23 @@ RUN apt-get install -y --no-install-recommends \
pcntl \
ldap \
gmp \
intl

# pecl will claim success even if one install fails, so we need to perform each install separately
RUN pecl install apcu-${apcu_version}; \
intl \
; \
\
# pecl will claim success even if one install fails, so we need to perform each install separately
pecl install apcu-${apcu_version}; \
pecl install memcached-${memcached_version}; \
pecl install redis-${redis_version}; \
pecl install imagick-${imagick_version}; \
\
docker-php-ext-enable \
apcu \
memcached \
redis \
imagick
imagick \
;



RUN apt-get clean -y && rm -rf /var/lib/apt/lists/*

Expand All @@ -94,3 +142,17 @@ RUN { \
\
mkdir /var/www/data; \
chmod -R g=u /var/www

RUN set -ex;\
a2enmod rewrite remoteip ;\
{\
echo RemoteIPHeader X-Real-IP ;\
echo RemoteIPTrustedProxy 10.0.0.0/8 ;\
echo RemoteIPTrustedProxy 172.16.0.0/12 ;\
echo RemoteIPTrustedProxy 192.168.0.0/16 ;\
} > /etc/apache2/conf-available/remoteip.conf;\
a2enconf remoteip

ENV FRIENDICA_VERSION "2025.02-dev"
ENV FRIENDICA_ADDONS "2025.02-dev"

12 changes: 6 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
// "features": {},

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bash -c '.devcontainer/postCreate.sh && .devcontainer/postCreateApacheSetup.sh && .devcontainer/postCreateFriendicaSetup.sh'",
"postStartCommand": "service apache2 start",
"postCreateCommand": "bash -c '.devcontainer/postCreate.sh'",
//"postStartCommand": "service apache2 start",

"forwardPorts": [
8080
],
//"forwardPorts": [
// 8080
//],

// Configure tool-specific properties.
"customizations": {
Expand All @@ -39,4 +39,4 @@

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
//"remoteUser": "root"
}
}
24 changes: 5 additions & 19 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,22 @@ services:
build:
context: .
dockerfile: Dockerfile

env_file: ".env"
volumes:
- ../..:/workspaces:cached
env_file: ".env"

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

ports:
- 80:80
- 443:443
- 8080:8080
- 3306:3306

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

extra_hosts:
- "${ServerAlias}:127.0.0.1"

db:
image: mariadb:10.4
image: mariadb:latest
restart: unless-stopped
volumes:
- mariadb-data:/var/lib/mysql
env_file: ".env"
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- friendica-data:/var/lib/mysql
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']

# Runs app on the same network as the app container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:app

Expand All @@ -45,7 +31,7 @@ services:
network_mode: service:app

volumes:
mariadb-data:
friendica-data:

networks:
default:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit e231007

Please sign in to comment.