Skip to content

Commit

Permalink
make container stuff compatible with podman, add devcontainer support
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jun 16, 2024
1 parent 788a5f5 commit b041080
Show file tree
Hide file tree
Showing 9 changed files with 637 additions and 141 deletions.
430 changes: 430 additions & 0 deletions .devcontainer/Dockerfile

Large diffs are not rendered by default.

95 changes: 72 additions & 23 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,74 @@
{
"name": "isp-net-adminator",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "opencodeco/phpctl:php83-devcontainer",
"image" : "php:5.6-apache",
"postCreateCommand": "composer install",
"features": {
// Install the Dapr CLI
// "ghcr.io/dapr/cli/dapr-cli:0": {},
"ghcr.io/devcontainers/features/sshd:1": {},
// Enable Docker (via Docker-in-Docker)
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
}
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.base.schema.json",

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu

"name": "isp-net-adminator",

// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/base:jammy",

"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.extend.yml"
],

"service": "fpm",

"workspaceFolder": "/srv/www",

"shutdownAction": "stopCompose",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "bash scripts/devcontainers-post-commands.sh",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
// "ms-azuretools.vscode-docker"
// ,"mads-hartmann.bash-ide-vscode"
// ,
// "EditorConfig.EditorConfig"
]
}
},

// Uncomment to connect as root instead.
// More info: https://aka.ms/dev-containers-non-root.
// Docs: https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
"remoteUser": "vscode"

// podman specific
// https://code.visualstudio.com/remote/advancedcontainers/docker-options#_podman
// ,
// "runArgs": [
// // run container as current user
// // "--userns=keep-id"
// // ,
// // // mount user home directory for things like git, ssh, and other configs
// // "--volume=${env:HOME}:${env:HOME}",
// // // ensure project directory is mounted incase it exists outside the home directory
// // "--volume=${localWorkspaceFolder}:${localWorkspaceFolder}",
// // isolate the .vscode-server folder so you don't overwrite settings from remote ssh vscode
// //"--volume=${localWorkspaceFolder}/.cache/vscode-server:${env:HOME}/.vscode-server"
// ]
,
"containerEnv": {
// ensure users home directory is the same inside the container as it is outside
"HOME": "/home/vscode"

}
// podman workaround for "mkdir: cannot create directory '/root': Permission denied"
// https://blog.lifeishao.com/post/vscode-replace-docker-with-podman/
// ,
// "containerUser": "vscode" // the value needs to match the value of "remoteUser"
}
21 changes: 21 additions & 0 deletions .devcontainer/docker-compose.extend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
fpm:
build:
# context: ../
dockerfile: .devcontainer/Dockerfile
# target: main
# args:
# progress: plain
volumes:
# Mounts the project folder to '/workspace'. While this file is in .devcontainer,
# mounts are relative to the first file in the list, which is a level up.
- .:/srv/www:cached

# [Optional] Required for ptrace-based debuggers like C++, Go, and Rust
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined

# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"
51 changes: 24 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ RUN apt-get update \
&& apt-get install -y \
libzip4 \
libpng16-16 \
msodbcsql17 \
msodbcsql18 \
libpq5 \
libgrpc29 \
diffutils
Expand Down Expand Up @@ -145,8 +145,8 @@ RUN mkdir -p /srv/www/adminator2/ \

RUN mkdir -p /srv/www/adminator3/ \
&& cd /srv/www/adminator3 \
&& mkdir temp log logs export \
&& chown www-data:www-data temp log logs export
&& mkdir temp logs export \
&& chown www-data:www-data temp logs export

COPY adminator2/composer.json /srv/www/adminator2/
COPY adminator3/composer.json /srv/www/adminator3/
Expand All @@ -159,20 +159,20 @@ RUN cd adminator3 \

# clean-up
RUN apt-get purge -y --allow-remove-essential \
libgcc-12-dev \
libstdc++-12-dev \
linux-libc-dev \
curl \
gnupg \
make \
m4 \
re2c \
pkg-config \
file \
unzip \
&& apt autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
libgcc-12-dev \
libstdc++-12-dev \
linux-libc-dev \
curl \
gnupg \
make \
m4 \
re2c \
pkg-config \
file \
unzip \
&& apt autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# app code
COPY adminator2/ /srv/www/adminator2/
Expand All @@ -185,6 +185,8 @@ COPY adminator3/include/main.function.shared.php /srv/www//adminator2/include/ma
RUN chmod 1777 /tmp \
&& cd adminator3 \
&& chown www-data:www-data export \
&& mkdir -p logs \
&& chown www-data:www-data logs \
&& cd print \
&& mkdir -p temp \
&& chown www-data:www-data temp
Expand All @@ -203,15 +205,13 @@ COPY ./configs/php-fpm-healthcheck /usr/local/bin/php-fpm-healthcheck

RUN chmod +x /usr/local/bin/php-fpm-healthcheck

# fix logging
# RUN mkdir -p /var/log/php \
# && chown -R www-data:www-data /var/log/php
# \
# && echo '' > /var/log/php/error.log

# # dont run as root
# USER www-data:www-data

COPY docker-php-entrypoint /usr/local/bin/docker-php-entrypoint

RUN chmod 0775 /usr/local/bin/docker-php-entrypoint

# workaround for squash
#
FROM scratch
Expand All @@ -226,10 +226,7 @@ RUN rm -rf /usr/bin/composer
#
ENV PHP_INI_DIR /usr/local/etc/php

ENTRYPOINT [ \
"chown www-data:www-data adminator3/export", \
"chown www-data:www-data adminator3/print/temp", \
"docker-php-entrypoint"]
ENTRYPOINT ["docker-php-entrypoint"]

WORKDIR /srv/www

Expand Down
6 changes: 3 additions & 3 deletions configs/nginx/vhosts/001-adminator2.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server {
listen 80;
server_name adminator2.192.168.1.213.nip.io;
server_name adminator2.127.0.0.1.nip.io;

root /srv/www/adminator2;
index index.php;
Expand Down Expand Up @@ -52,5 +52,5 @@ server {
fastcgi_index index.php;
fastcgi_pass fpm:9002;
}
}

}
8 changes: 4 additions & 4 deletions configs/nginx/vhosts/002-adminator3.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server {
listen 80;
server_name adminator3.192.168.1.213.nip.io;
server_name adminator3.127.0.0.1.nip.io;

root /srv/www/adminator3;
index index.php;
Expand All @@ -25,12 +25,12 @@ server {
deny all;
return 403;
}

location ~* /print/temp {
deny all;
return 403;
}

location ~ (Dockerfile|Makefile)$ {
deny all;
return 403;
Expand All @@ -53,4 +53,4 @@ server {
fastcgi_pass fpm:9002;
}

}
}
Loading

0 comments on commit b041080

Please sign in to comment.